xref: /linux/drivers/input/serio/i8042-acpipnpio.h (revision c1a5135e60f1a026f135c6b0964cc8f4e1c4a8bb)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _I8042_ACPIPNPIO_H
3 #define _I8042_ACPIPNPIO_H
4 
5 #include <linux/acpi.h>
6 
7 #ifdef CONFIG_X86
8 #include <asm/x86_init.h>
9 #endif
10 
11 /*
12  * Names.
13  */
14 
15 #define I8042_KBD_PHYS_DESC "isa0060/serio0"
16 #define I8042_AUX_PHYS_DESC "isa0060/serio1"
17 #define I8042_MUX_PHYS_DESC "isa0060/serio%d"
18 
19 /*
20  * IRQs.
21  */
22 
23 #if defined(__ia64__)
24 # define I8042_MAP_IRQ(x)	isa_irq_to_vector((x))
25 #else
26 # define I8042_MAP_IRQ(x)	(x)
27 #endif
28 
29 #define I8042_KBD_IRQ	i8042_kbd_irq
30 #define I8042_AUX_IRQ	i8042_aux_irq
31 
32 static int i8042_kbd_irq;
33 static int i8042_aux_irq;
34 
35 /*
36  * Register numbers.
37  */
38 
39 #define I8042_COMMAND_REG	i8042_command_reg
40 #define I8042_STATUS_REG	i8042_command_reg
41 #define I8042_DATA_REG		i8042_data_reg
42 
43 static int i8042_command_reg = 0x64;
44 static int i8042_data_reg = 0x60;
45 
46 
i8042_read_data(void)47 static inline int i8042_read_data(void)
48 {
49 	return inb(I8042_DATA_REG);
50 }
51 
i8042_read_status(void)52 static inline int i8042_read_status(void)
53 {
54 	return inb(I8042_STATUS_REG);
55 }
56 
i8042_write_data(int val)57 static inline void i8042_write_data(int val)
58 {
59 	outb(val, I8042_DATA_REG);
60 }
61 
i8042_write_command(int val)62 static inline void i8042_write_command(int val)
63 {
64 	outb(val, I8042_COMMAND_REG);
65 }
66 
67 #ifdef CONFIG_X86
68 
69 #include <linux/dmi.h>
70 
71 #define SERIO_QUIRK_NOKBD		BIT(0)
72 #define SERIO_QUIRK_NOAUX		BIT(1)
73 #define SERIO_QUIRK_NOMUX		BIT(2)
74 #define SERIO_QUIRK_FORCEMUX		BIT(3)
75 #define SERIO_QUIRK_UNLOCK		BIT(4)
76 #define SERIO_QUIRK_PROBE_DEFER		BIT(5)
77 #define SERIO_QUIRK_RESET_ALWAYS	BIT(6)
78 #define SERIO_QUIRK_RESET_NEVER		BIT(7)
79 #define SERIO_QUIRK_DIRECT		BIT(8)
80 #define SERIO_QUIRK_DUMBKBD		BIT(9)
81 #define SERIO_QUIRK_NOLOOP		BIT(10)
82 #define SERIO_QUIRK_NOTIMEOUT		BIT(11)
83 #define SERIO_QUIRK_KBDRESET		BIT(12)
84 #define SERIO_QUIRK_DRITEK		BIT(13)
85 #define SERIO_QUIRK_NOPNP		BIT(14)
86 #define SERIO_QUIRK_FORCENORESTORE	BIT(15)
87 
88 /* Quirk table for different mainboards. Options similar or identical to i8042
89  * module parameters.
90  * ORDERING IS IMPORTANT! The first match will be apllied and the rest ignored.
91  * This allows entries to overwrite vendor wide quirks on a per device basis.
92  * Where this is irrelevant, entries are sorted case sensitive by DMI_SYS_VENDOR
93  * and/or DMI_BOARD_VENDOR to make it easier to avoid duplicate entries.
94  */
95 static const struct dmi_system_id i8042_dmi_quirk_table[] __initconst = {
96 	{
97 		.matches = {
98 			DMI_MATCH(DMI_SYS_VENDOR, "ALIENWARE"),
99 			DMI_MATCH(DMI_PRODUCT_NAME, "Sentia"),
100 		},
101 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
102 	},
103 	{
104 		.matches = {
105 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
106 			DMI_MATCH(DMI_PRODUCT_NAME, "X750LN"),
107 		},
108 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
109 	},
110 	{
111 		/* Asus X450LCP */
112 		.matches = {
113 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
114 			DMI_MATCH(DMI_PRODUCT_NAME, "X450LCP"),
115 		},
116 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_NEVER)
117 	},
118 	{
119 		/*
120 		 * ASUS Zenbook UX425QA_UM425QA
121 		 * Some Zenbooks report "Zenbook" with a lowercase b.
122 		 */
123 		.matches = {
124 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
125 			DMI_MATCH(DMI_PRODUCT_NAME, "Zenbook UX425QA_UM425QA"),
126 		},
127 		.driver_data = (void *)(SERIO_QUIRK_PROBE_DEFER | SERIO_QUIRK_RESET_NEVER)
128 	},
129 	{
130 		/* ASUS ZenBook UX425UA/QA */
131 		.matches = {
132 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
133 			DMI_MATCH(DMI_PRODUCT_NAME, "ZenBook UX425"),
134 		},
135 		.driver_data = (void *)(SERIO_QUIRK_PROBE_DEFER | SERIO_QUIRK_RESET_NEVER)
136 	},
137 	{
138 		/* ASUS ZenBook UM325UA/QA */
139 		.matches = {
140 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
141 			DMI_MATCH(DMI_PRODUCT_NAME, "ZenBook UX325"),
142 		},
143 		.driver_data = (void *)(SERIO_QUIRK_PROBE_DEFER | SERIO_QUIRK_RESET_NEVER)
144 	},
145 	/*
146 	 * On some Asus laptops, just running self tests cause problems.
147 	 */
148 	{
149 		.matches = {
150 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
151 			DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
152 		},
153 		.driver_data = (void *)(SERIO_QUIRK_RESET_NEVER)
154 	},
155 	{
156 		.matches = {
157 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
158 			DMI_MATCH(DMI_CHASSIS_TYPE, "31"), /* Convertible Notebook */
159 		},
160 		.driver_data = (void *)(SERIO_QUIRK_RESET_NEVER)
161 	},
162 	{
163 		/* ASUS P65UP5 - AUX LOOP command does not raise AUX IRQ */
164 		.matches = {
165 			DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
166 			DMI_MATCH(DMI_BOARD_NAME, "P/I-P65UP5"),
167 			DMI_MATCH(DMI_BOARD_VERSION, "REV 2.X"),
168 		},
169 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
170 	},
171 	{
172 		/* ASUS G1S */
173 		.matches = {
174 			DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."),
175 			DMI_MATCH(DMI_BOARD_NAME, "G1S"),
176 			DMI_MATCH(DMI_BOARD_VERSION, "1.0"),
177 		},
178 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
179 	},
180 	{
181 		.matches = {
182 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
183 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 1360"),
184 		},
185 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
186 	},
187 	{
188 		/* Acer Aspire 5710 */
189 		.matches = {
190 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
191 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5710"),
192 		},
193 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
194 	},
195 	{
196 		/* Acer Aspire 7738 */
197 		.matches = {
198 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
199 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 7738"),
200 		},
201 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
202 	},
203 	{
204 		/* Acer Aspire 5536 */
205 		.matches = {
206 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
207 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5536"),
208 			DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
209 		},
210 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
211 	},
212 	{
213 		/*
214 		 * Acer Aspire 5738z
215 		 * Touchpad stops working in mux mode when dis- + re-enabled
216 		 * with the touchpad enable/disable toggle hotkey
217 		 */
218 		.matches = {
219 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
220 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5738"),
221 		},
222 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
223 	},
224 	{
225 		/* Acer Aspire One 150 */
226 		.matches = {
227 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
228 			DMI_MATCH(DMI_PRODUCT_NAME, "AOA150"),
229 		},
230 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
231 	},
232 	{
233 		/* Acer Aspire One 532h */
234 		.matches = {
235 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
236 			DMI_MATCH(DMI_PRODUCT_NAME, "AO532h"),
237 		},
238 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
239 	},
240 	{
241 		.matches = {
242 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
243 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire A114-31"),
244 		},
245 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
246 	},
247 	{
248 		.matches = {
249 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
250 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire A314-31"),
251 		},
252 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
253 	},
254 	{
255 		.matches = {
256 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
257 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire A315-31"),
258 		},
259 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
260 	},
261 	{
262 		.matches = {
263 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
264 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire ES1-132"),
265 		},
266 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
267 	},
268 	{
269 		.matches = {
270 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
271 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire ES1-332"),
272 		},
273 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
274 	},
275 	{
276 		.matches = {
277 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
278 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire ES1-432"),
279 		},
280 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
281 	},
282 	{
283 		.matches = {
284 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
285 			DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate Spin B118-RN"),
286 		},
287 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
288 	},
289 	/*
290 	 * Some Wistron based laptops need us to explicitly enable the 'Dritek
291 	 * keyboard extension' to make their extra keys start generating scancodes.
292 	 * Originally, this was just confined to older laptops, but a few Acer laptops
293 	 * have turned up in 2007 that also need this again.
294 	 */
295 	{
296 		/* Acer Aspire 5100 */
297 		.matches = {
298 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
299 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"),
300 		},
301 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
302 	},
303 	{
304 		/* Acer Aspire 5610 */
305 		.matches = {
306 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
307 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
308 		},
309 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
310 	},
311 	{
312 		/* Acer Aspire 5630 */
313 		.matches = {
314 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
315 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"),
316 		},
317 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
318 	},
319 	{
320 		/* Acer Aspire 5650 */
321 		.matches = {
322 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
323 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
324 		},
325 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
326 	},
327 	{
328 		/* Acer Aspire 5680 */
329 		.matches = {
330 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
331 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
332 		},
333 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
334 	},
335 	{
336 		/* Acer Aspire 5720 */
337 		.matches = {
338 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
339 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
340 		},
341 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
342 	},
343 	{
344 		/* Acer Aspire 9110 */
345 		.matches = {
346 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
347 			DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9110"),
348 		},
349 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
350 	},
351 	{
352 		/* Acer TravelMate 660 */
353 		.matches = {
354 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
355 			DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
356 		},
357 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
358 	},
359 	{
360 		/* Acer TravelMate 2490 */
361 		.matches = {
362 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
363 			DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
364 		},
365 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
366 	},
367 	{
368 		/* Acer TravelMate 4280 */
369 		.matches = {
370 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
371 			DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4280"),
372 		},
373 		.driver_data = (void *)(SERIO_QUIRK_DRITEK)
374 	},
375 	{
376 		/* Acer TravelMate P459-G2-M */
377 		.matches = {
378 			DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
379 			DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate P459-G2-M"),
380 		},
381 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
382 	},
383 	{
384 		/* Amoi M636/A737 */
385 		.matches = {
386 			DMI_MATCH(DMI_SYS_VENDOR, "Amoi Electronics CO.,LTD."),
387 			DMI_MATCH(DMI_PRODUCT_NAME, "M636/A737 platform"),
388 		},
389 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
390 	},
391 	{
392 		.matches = {
393 			DMI_MATCH(DMI_SYS_VENDOR, "ByteSpeed LLC"),
394 			DMI_MATCH(DMI_PRODUCT_NAME, "ByteSpeed Laptop C15B"),
395 		},
396 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
397 	},
398 	{
399 		/* Compal HEL80I */
400 		.matches = {
401 			DMI_MATCH(DMI_SYS_VENDOR, "COMPAL"),
402 			DMI_MATCH(DMI_PRODUCT_NAME, "HEL80I"),
403 		},
404 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
405 	},
406 	{
407 		.matches = {
408 			DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
409 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant"),
410 			DMI_MATCH(DMI_PRODUCT_VERSION, "8500"),
411 		},
412 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
413 	},
414 	{
415 		.matches = {
416 			DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
417 			DMI_MATCH(DMI_PRODUCT_NAME, "ProLiant"),
418 			DMI_MATCH(DMI_PRODUCT_VERSION, "DL760"),
419 		},
420 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
421 	},
422 	{
423 		/* Advent 4211 */
424 		.matches = {
425 			DMI_MATCH(DMI_SYS_VENDOR, "DIXONSXP"),
426 			DMI_MATCH(DMI_PRODUCT_NAME, "Advent 4211"),
427 		},
428 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
429 	},
430 	{
431 		/* Dell Embedded Box PC 3000 */
432 		.matches = {
433 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
434 			DMI_MATCH(DMI_PRODUCT_NAME, "Embedded Box PC 3000"),
435 		},
436 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
437 	},
438 	{
439 		/* Dell XPS M1530 */
440 		.matches = {
441 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
442 			DMI_MATCH(DMI_PRODUCT_NAME, "XPS M1530"),
443 		},
444 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
445 	},
446 	{
447 		/* Dell Vostro 1510 */
448 		.matches = {
449 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
450 			DMI_MATCH(DMI_PRODUCT_NAME, "Vostro1510"),
451 		},
452 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
453 	},
454 	{
455 		/* Dell Vostro V13 */
456 		.matches = {
457 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
458 			DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V13"),
459 		},
460 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_NOTIMEOUT)
461 	},
462 	{
463 		/* Dell Vostro 1320 */
464 		.matches = {
465 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
466 			DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1320"),
467 		},
468 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
469 	},
470 	{
471 		/* Dell Vostro 1520 */
472 		.matches = {
473 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
474 			DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1520"),
475 		},
476 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
477 	},
478 	{
479 		/* Dell Vostro 1720 */
480 		.matches = {
481 			DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
482 			DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1720"),
483 		},
484 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
485 	},
486 	{
487 		/* Entroware Proteus */
488 		.matches = {
489 			DMI_MATCH(DMI_SYS_VENDOR, "Entroware"),
490 			DMI_MATCH(DMI_PRODUCT_NAME, "Proteus"),
491 			DMI_MATCH(DMI_PRODUCT_VERSION, "EL07R4"),
492 		},
493 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS)
494 	},
495 	/*
496 	 * Some Fujitsu notebooks are having trouble with touchpads if
497 	 * active multiplexing mode is activated. Luckily they don't have
498 	 * external PS/2 ports so we can safely disable it.
499 	 * ... apparently some Toshibas don't like MUX mode either and
500 	 * die horrible death on reboot.
501 	 */
502 	{
503 		/* Fujitsu Lifebook P7010/P7010D */
504 		.matches = {
505 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
506 			DMI_MATCH(DMI_PRODUCT_NAME, "P7010"),
507 		},
508 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
509 	},
510 	{
511 		/* Fujitsu Lifebook P5020D */
512 		.matches = {
513 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
514 			DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook P Series"),
515 		},
516 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
517 	},
518 	{
519 		/* Fujitsu Lifebook S2000 */
520 		.matches = {
521 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
522 			DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S Series"),
523 		},
524 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
525 	},
526 	{
527 		/* Fujitsu Lifebook S6230 */
528 		.matches = {
529 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
530 			DMI_MATCH(DMI_PRODUCT_NAME, "LifeBook S6230"),
531 		},
532 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
533 	},
534 	{
535 		/* Fujitsu Lifebook T725 laptop */
536 		.matches = {
537 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
538 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T725"),
539 		},
540 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_NOTIMEOUT)
541 	},
542 	{
543 		/* Fujitsu Lifebook U745 */
544 		.matches = {
545 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
546 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U745"),
547 		},
548 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
549 	},
550 	{
551 		/* Fujitsu T70H */
552 		.matches = {
553 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
554 			DMI_MATCH(DMI_PRODUCT_NAME, "FMVLT70H"),
555 		},
556 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
557 	},
558 	{
559 		/* Fujitsu A544 laptop */
560 		/* https://bugzilla.redhat.com/show_bug.cgi?id=1111138 */
561 		.matches = {
562 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
563 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK A544"),
564 		},
565 		.driver_data = (void *)(SERIO_QUIRK_NOTIMEOUT)
566 	},
567 	{
568 		/* Fujitsu AH544 laptop */
569 		/* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
570 		.matches = {
571 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
572 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK AH544"),
573 		},
574 		.driver_data = (void *)(SERIO_QUIRK_NOTIMEOUT)
575 	},
576 	{
577 		/* Fujitsu U574 laptop */
578 		/* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
579 		.matches = {
580 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
581 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U574"),
582 		},
583 		.driver_data = (void *)(SERIO_QUIRK_NOTIMEOUT)
584 	},
585 	{
586 		/* Fujitsu UH554 laptop */
587 		.matches = {
588 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
589 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK UH544"),
590 		},
591 		.driver_data = (void *)(SERIO_QUIRK_NOTIMEOUT)
592 	},
593 	{
594 		/* Fujitsu Lifebook P7010 */
595 		.matches = {
596 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
597 			DMI_MATCH(DMI_PRODUCT_NAME, "0000000000"),
598 		},
599 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
600 	},
601 	{
602 		/* Fujitsu-Siemens Lifebook T3010 */
603 		.matches = {
604 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
605 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK T3010"),
606 		},
607 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
608 	},
609 	{
610 		/* Fujitsu-Siemens Lifebook E4010 */
611 		.matches = {
612 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
613 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E4010"),
614 		},
615 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
616 	},
617 	{
618 		/* Fujitsu-Siemens Amilo Pro 2010 */
619 		.matches = {
620 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
621 			DMI_MATCH(DMI_PRODUCT_NAME, "AMILO Pro V2010"),
622 		},
623 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
624 	},
625 	{
626 		/* Fujitsu-Siemens Amilo Pro 2030 */
627 		.matches = {
628 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"),
629 			DMI_MATCH(DMI_PRODUCT_NAME, "AMILO PRO V2030"),
630 		},
631 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
632 	},
633 	{
634 		/* Fujitsu Lifebook A574/H */
635 		.matches = {
636 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
637 			DMI_MATCH(DMI_PRODUCT_NAME, "FMVA0501PZ"),
638 		},
639 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
640 	},
641 	{
642 		/* Fujitsu Lifebook E756 */
643 		/* https://bugzilla.suse.com/show_bug.cgi?id=1229056 */
644 		.matches = {
645 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
646 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E756"),
647 		},
648 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
649 	},
650 	{
651 		/* Fujitsu Lifebook E5411 */
652 		.matches = {
653 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU CLIENT COMPUTING LIMITED"),
654 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK E5411"),
655 		},
656 		.driver_data = (void *)(SERIO_QUIRK_NOAUX)
657 	},
658 	{
659 		/* Fujitsu Lifebook U728 */
660 		.matches = {
661 			DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
662 			DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U728"),
663 		},
664 		.driver_data = (void *)(SERIO_QUIRK_NOAUX)
665 	},
666 	{
667 		/* Gigabyte M912 */
668 		.matches = {
669 			DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
670 			DMI_MATCH(DMI_PRODUCT_NAME, "M912"),
671 			DMI_MATCH(DMI_PRODUCT_VERSION, "01"),
672 		},
673 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
674 	},
675 	{
676 		/* Gigabyte Spring Peak - defines wrong chassis type */
677 		.matches = {
678 			DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
679 			DMI_MATCH(DMI_PRODUCT_NAME, "Spring Peak"),
680 		},
681 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
682 	},
683 	{
684 		/* Gigabyte T1005 - defines wrong chassis type ("Other") */
685 		.matches = {
686 			DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
687 			DMI_MATCH(DMI_PRODUCT_NAME, "T1005"),
688 		},
689 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
690 	},
691 	{
692 		/* Gigabyte T1005M/P - defines wrong chassis type ("Other") */
693 		.matches = {
694 			DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
695 			DMI_MATCH(DMI_PRODUCT_NAME, "T1005M/P"),
696 		},
697 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
698 	},
699 	/*
700 	 * Some laptops need keyboard reset before probing for the trackpad to get
701 	 * it detected, initialised & finally work.
702 	 */
703 	{
704 		/* Gigabyte P35 v2 - Elantech touchpad */
705 		.matches = {
706 			DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
707 			DMI_MATCH(DMI_PRODUCT_NAME, "P35V2"),
708 		},
709 		.driver_data = (void *)(SERIO_QUIRK_KBDRESET)
710 	},
711 		{
712 		/* Aorus branded Gigabyte X3 Plus - Elantech touchpad */
713 		.matches = {
714 			DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
715 			DMI_MATCH(DMI_PRODUCT_NAME, "X3"),
716 		},
717 		.driver_data = (void *)(SERIO_QUIRK_KBDRESET)
718 	},
719 	{
720 		/* Gigabyte P34 - Elantech touchpad */
721 		.matches = {
722 			DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
723 			DMI_MATCH(DMI_PRODUCT_NAME, "P34"),
724 		},
725 		.driver_data = (void *)(SERIO_QUIRK_KBDRESET)
726 	},
727 	{
728 		/* Gigabyte P57 - Elantech touchpad */
729 		.matches = {
730 			DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
731 			DMI_MATCH(DMI_PRODUCT_NAME, "P57"),
732 		},
733 		.driver_data = (void *)(SERIO_QUIRK_KBDRESET)
734 	},
735 	{
736 		/* Gericom Bellagio */
737 		.matches = {
738 			DMI_MATCH(DMI_SYS_VENDOR, "Gericom"),
739 			DMI_MATCH(DMI_PRODUCT_NAME, "N34AS6"),
740 		},
741 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
742 	},
743 	{
744 		/* Gigabyte M1022M netbook */
745 		.matches = {
746 			DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co.,Ltd."),
747 			DMI_MATCH(DMI_BOARD_NAME, "M1022E"),
748 			DMI_MATCH(DMI_BOARD_VERSION, "1.02"),
749 		},
750 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
751 	},
752 	{
753 		.matches = {
754 			DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
755 			DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"),
756 			DMI_MATCH(DMI_PRODUCT_VERSION, "Rev 1"),
757 		},
758 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
759 	},
760 	{
761 		/*
762 		 * HP Pavilion DV4017EA -
763 		 * errors on MUX ports are reported without raising AUXDATA
764 		 * causing "spurious NAK" messages.
765 		 */
766 		.matches = {
767 			DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
768 			DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EA032EA#ABF)"),
769 		},
770 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
771 	},
772 	{
773 		/*
774 		 * HP Pavilion ZT1000 -
775 		 * like DV4017EA does not raise AUXERR for errors on MUX ports.
776 		 */
777 		.matches = {
778 			DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
779 			DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion Notebook PC"),
780 			DMI_MATCH(DMI_PRODUCT_VERSION, "HP Pavilion Notebook ZT1000"),
781 		},
782 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
783 	},
784 	{
785 		/*
786 		 * HP Pavilion DV4270ca -
787 		 * like DV4017EA does not raise AUXERR for errors on MUX ports.
788 		 */
789 		.matches = {
790 			DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
791 			DMI_MATCH(DMI_PRODUCT_NAME, "Pavilion dv4000 (EH476UA#ABL)"),
792 		},
793 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
794 	},
795 	{
796 		/* Newer HP Pavilion dv4 models */
797 		.matches = {
798 			DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
799 			DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"),
800 		},
801 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_NOTIMEOUT)
802 	},
803 	{
804 		/* IBM 2656 */
805 		.matches = {
806 			DMI_MATCH(DMI_SYS_VENDOR, "IBM"),
807 			DMI_MATCH(DMI_PRODUCT_NAME, "2656"),
808 		},
809 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
810 	},
811 	{
812 		/* Avatar AVIU-145A6 */
813 		.matches = {
814 			DMI_MATCH(DMI_SYS_VENDOR, "Intel"),
815 			DMI_MATCH(DMI_PRODUCT_NAME, "IC4I"),
816 		},
817 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
818 	},
819 	{
820 		/* Intel MBO Desktop D845PESV */
821 		.matches = {
822 			DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
823 			DMI_MATCH(DMI_BOARD_NAME, "D845PESV"),
824 		},
825 		.driver_data = (void *)(SERIO_QUIRK_NOPNP)
826 	},
827 	{
828 		/*
829 		 * Intel NUC D54250WYK - does not have i8042 controller but
830 		 * declares PS/2 devices in DSDT.
831 		 */
832 		.matches = {
833 			DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
834 			DMI_MATCH(DMI_BOARD_NAME, "D54250WYK"),
835 		},
836 		.driver_data = (void *)(SERIO_QUIRK_NOPNP)
837 	},
838 	{
839 		/* Lenovo 3000 n100 */
840 		.matches = {
841 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
842 			DMI_MATCH(DMI_PRODUCT_NAME, "076804U"),
843 		},
844 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
845 	},
846 	{
847 		/* Lenovo XiaoXin Air 12 */
848 		.matches = {
849 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
850 			DMI_MATCH(DMI_PRODUCT_NAME, "80UN"),
851 		},
852 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
853 	},
854 	{
855 		/* Lenovo LaVie Z */
856 		.matches = {
857 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
858 			DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo LaVie Z"),
859 		},
860 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
861 	},
862 	{
863 		/* Lenovo Ideapad U455 */
864 		.matches = {
865 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
866 			DMI_MATCH(DMI_PRODUCT_NAME, "20046"),
867 		},
868 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
869 	},
870 	{
871 		/* Lenovo ThinkPad L460 */
872 		.matches = {
873 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
874 			DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L460"),
875 		},
876 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
877 	},
878 	{
879 		/* Lenovo ThinkPad Twist S230u */
880 		.matches = {
881 			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
882 			DMI_MATCH(DMI_PRODUCT_NAME, "33474HU"),
883 		},
884 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
885 	},
886 	{
887 		/* LG Electronics X110 */
888 		.matches = {
889 			DMI_MATCH(DMI_BOARD_VENDOR, "LG Electronics Inc."),
890 			DMI_MATCH(DMI_BOARD_NAME, "X110"),
891 		},
892 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
893 	},
894 	{
895 		/* Medion Akoya Mini E1210 */
896 		.matches = {
897 			DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
898 			DMI_MATCH(DMI_PRODUCT_NAME, "E1210"),
899 		},
900 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
901 	},
902 	{
903 		/* Medion Akoya E1222 */
904 		.matches = {
905 			DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
906 			DMI_MATCH(DMI_PRODUCT_NAME, "E122X"),
907 		},
908 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
909 	},
910 	{
911 		/* MSI Wind U-100 */
912 		.matches = {
913 			DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
914 			DMI_MATCH(DMI_BOARD_NAME, "U-100"),
915 		},
916 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS | SERIO_QUIRK_NOPNP)
917 	},
918 	{
919 		/*
920 		 * No data is coming from the touchscreen unless KBC
921 		 * is in legacy mode.
922 		 */
923 		/* Panasonic CF-29 */
924 		.matches = {
925 			DMI_MATCH(DMI_SYS_VENDOR, "Matsushita"),
926 			DMI_MATCH(DMI_PRODUCT_NAME, "CF-29"),
927 		},
928 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
929 	},
930 	{
931 		/* Medion Akoya E7225 */
932 		.matches = {
933 			DMI_MATCH(DMI_SYS_VENDOR, "Medion"),
934 			DMI_MATCH(DMI_PRODUCT_NAME, "Akoya E7225"),
935 			DMI_MATCH(DMI_PRODUCT_VERSION, "1.0"),
936 		},
937 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
938 	},
939 	{
940 		/* Microsoft Virtual Machine */
941 		.matches = {
942 			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
943 			DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
944 			DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"),
945 		},
946 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
947 	},
948 	{
949 		/* Medion MAM 2070 */
950 		.matches = {
951 			DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
952 			DMI_MATCH(DMI_PRODUCT_NAME, "MAM 2070"),
953 			DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
954 		},
955 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
956 	},
957 	{
958 		/* TUXEDO BU1406 */
959 		.matches = {
960 			DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
961 			DMI_MATCH(DMI_PRODUCT_NAME, "N24_25BU"),
962 		},
963 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
964 	},
965 	{
966 		/* OQO Model 01 */
967 		.matches = {
968 			DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
969 			DMI_MATCH(DMI_PRODUCT_NAME, "ZEPTO"),
970 			DMI_MATCH(DMI_PRODUCT_VERSION, "00"),
971 		},
972 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
973 	},
974 	{
975 		.matches = {
976 			DMI_MATCH(DMI_SYS_VENDOR, "PEGATRON CORPORATION"),
977 			DMI_MATCH(DMI_PRODUCT_NAME, "C15B"),
978 		},
979 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
980 	},
981 	{
982 		/* Acer Aspire 5 A515 */
983 		.matches = {
984 			DMI_MATCH(DMI_BOARD_VENDOR, "PK"),
985 			DMI_MATCH(DMI_BOARD_NAME, "Grumpy_PK"),
986 		},
987 		.driver_data = (void *)(SERIO_QUIRK_NOPNP)
988 	},
989 	{
990 		/* ULI EV4873 - AUX LOOP does not work properly */
991 		.matches = {
992 			DMI_MATCH(DMI_SYS_VENDOR, "ULI"),
993 			DMI_MATCH(DMI_PRODUCT_NAME, "EV4873"),
994 			DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
995 		},
996 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
997 	},
998 	{
999 		/*
1000 		 * Arima-Rioworks HDAMB -
1001 		 * AUX LOOP command does not raise AUX IRQ
1002 		 */
1003 		.matches = {
1004 			DMI_MATCH(DMI_BOARD_VENDOR, "RIOWORKS"),
1005 			DMI_MATCH(DMI_BOARD_NAME, "HDAMB"),
1006 			DMI_MATCH(DMI_BOARD_VERSION, "Rev E"),
1007 		},
1008 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
1009 	},
1010 	{
1011 		/* Sharp Actius MM20 */
1012 		.matches = {
1013 			DMI_MATCH(DMI_SYS_VENDOR, "SHARP"),
1014 			DMI_MATCH(DMI_PRODUCT_NAME, "PC-MM20 Series"),
1015 		},
1016 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
1017 	},
1018 	{
1019 		/*
1020 		 * Sony Vaio FZ-240E -
1021 		 * reset and GET ID commands issued via KBD port are
1022 		 * sometimes being delivered to AUX3.
1023 		 */
1024 		.matches = {
1025 			DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
1026 			DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FZ240E"),
1027 		},
1028 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
1029 	},
1030 	{
1031 		/*
1032 		 * Most (all?) VAIOs do not have external PS/2 ports nor
1033 		 * they implement active multiplexing properly, and
1034 		 * MUX discovery usually messes up keyboard/touchpad.
1035 		 */
1036 		.matches = {
1037 			DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
1038 			DMI_MATCH(DMI_BOARD_NAME, "VAIO"),
1039 		},
1040 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
1041 	},
1042 	{
1043 		/* Sony Vaio FS-115b */
1044 		.matches = {
1045 			DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
1046 			DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FS115B"),
1047 		},
1048 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
1049 	},
1050 	{
1051 		/*
1052 		 * Sony Vaio VGN-CS series require MUX or the touch sensor
1053 		 * buttons will disturb touchpad operation
1054 		 */
1055 		.matches = {
1056 			DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
1057 			DMI_MATCH(DMI_PRODUCT_NAME, "VGN-CS"),
1058 		},
1059 		.driver_data = (void *)(SERIO_QUIRK_FORCEMUX)
1060 	},
1061 	{
1062 		.matches = {
1063 			DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
1064 			DMI_MATCH(DMI_PRODUCT_NAME, "Satellite P10"),
1065 		},
1066 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
1067 	},
1068 	{
1069 		.matches = {
1070 			DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
1071 			DMI_MATCH(DMI_PRODUCT_NAME, "EQUIUM A110"),
1072 		},
1073 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
1074 	},
1075 	{
1076 		.matches = {
1077 			DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
1078 			DMI_MATCH(DMI_PRODUCT_NAME, "SATELLITE C850D"),
1079 		},
1080 		.driver_data = (void *)(SERIO_QUIRK_NOMUX)
1081 	},
1082 	/*
1083 	 * A lot of modern Clevo barebones have touchpad and/or keyboard issues
1084 	 * after suspend fixable with nomux + reset + noloop + nopnp. Luckily,
1085 	 * none of them have an external PS/2 port so this can safely be set for
1086 	 * all of them. These two are based on a Clevo design, but have the
1087 	 * board_name changed.
1088 	 */
1089 	{
1090 		.matches = {
1091 			DMI_MATCH(DMI_BOARD_VENDOR, "TUXEDO"),
1092 			DMI_MATCH(DMI_BOARD_NAME, "AURA1501"),
1093 		},
1094 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1095 	},
1096 	{
1097 		.matches = {
1098 			DMI_MATCH(DMI_BOARD_VENDOR, "TUXEDO"),
1099 			DMI_MATCH(DMI_BOARD_NAME, "EDUBOOK1502"),
1100 		},
1101 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1102 	},
1103 	{
1104 		/* Mivvy M310 */
1105 		.matches = {
1106 			DMI_MATCH(DMI_SYS_VENDOR, "VIOOO"),
1107 			DMI_MATCH(DMI_PRODUCT_NAME, "N10"),
1108 		},
1109 		.driver_data = (void *)(SERIO_QUIRK_RESET_ALWAYS)
1110 	},
1111 	/*
1112 	 * Some laptops need keyboard reset before probing for the trackpad to get
1113 	 * it detected, initialised & finally work.
1114 	 */
1115 	{
1116 		/* Schenker XMG C504 - Elantech touchpad */
1117 		.matches = {
1118 			DMI_MATCH(DMI_SYS_VENDOR, "XMG"),
1119 			DMI_MATCH(DMI_PRODUCT_NAME, "C504"),
1120 		},
1121 		.driver_data = (void *)(SERIO_QUIRK_KBDRESET)
1122 	},
1123 	{
1124 		/* Blue FB5601 */
1125 		.matches = {
1126 			DMI_MATCH(DMI_SYS_VENDOR, "blue"),
1127 			DMI_MATCH(DMI_PRODUCT_NAME, "FB5601"),
1128 			DMI_MATCH(DMI_PRODUCT_VERSION, "M606"),
1129 		},
1130 		.driver_data = (void *)(SERIO_QUIRK_NOLOOP)
1131 	},
1132 	/*
1133 	 * Some TongFang barebones have touchpad and/or keyboard issues after
1134 	 * suspend fixable with nomux + reset + noloop + nopnp. Luckily, none of
1135 	 * them have an external PS/2 port so this can safely be set for all of
1136 	 * them.
1137 	 * TongFang barebones come with board_vendor and/or system_vendor set to
1138 	 * a different value for each individual reseller. The only somewhat
1139 	 * universal way to identify them is by board_name.
1140 	 */
1141 	{
1142 		.matches = {
1143 			DMI_MATCH(DMI_BOARD_NAME, "GM6XGxX"),
1144 		},
1145 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS |
1146 					SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP)
1147 	},
1148 	{
1149 		.matches = {
1150 			DMI_MATCH(DMI_BOARD_NAME, "GMxXGxx"),
1151 		},
1152 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS |
1153 					SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP)
1154 	},
1155 	{
1156 		.matches = {
1157 			DMI_MATCH(DMI_BOARD_NAME, "GMxXGxX"),
1158 		},
1159 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS |
1160 					SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP)
1161 	},
1162 	{
1163 		.matches = {
1164 			DMI_MATCH(DMI_BOARD_NAME, "GMxHGxx"),
1165 		},
1166 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS |
1167 					SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP)
1168 	},
1169 	{
1170 		.matches = {
1171 			DMI_MATCH(DMI_BOARD_NAME, "XxHP4NAx"),
1172 		},
1173 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS |
1174 					SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP)
1175 	},
1176 	{
1177 		.matches = {
1178 			DMI_MATCH(DMI_BOARD_NAME, "XxKK4NAx_XxSP4NAx"),
1179 		},
1180 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS |
1181 					SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP)
1182 	},
1183 	{
1184 		.matches = {
1185 			DMI_MATCH(DMI_BOARD_NAME, "X5KK45xS_X5SP45xS"),
1186 		},
1187 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS |
1188 					SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP)
1189 	},
1190 	{
1191 		.matches = {
1192 			DMI_MATCH(DMI_BOARD_NAME, "WUJIE Series-X5SP4NAG"),
1193 		},
1194 		.driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS |
1195 					SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP)
1196 	},
1197 	/*
1198 	 * A lot of modern Clevo barebones have touchpad and/or keyboard issues
1199 	 * after suspend fixable with the forcenorestore quirk.
1200 	 * Clevo barebones come with board_vendor and/or system_vendor set to
1201 	 * either the very generic string "Notebook" and/or a different value
1202 	 * for each individual reseller. The only somewhat universal way to
1203 	 * identify them is by board_name.
1204 	 */
1205 	{
1206 		.matches = {
1207 			DMI_MATCH(DMI_BOARD_NAME, "LAPQC71A"),
1208 		},
1209 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1210 	},
1211 	{
1212 		.matches = {
1213 			DMI_MATCH(DMI_BOARD_NAME, "LAPQC71B"),
1214 		},
1215 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1216 	},
1217 	{
1218 		.matches = {
1219 			DMI_MATCH(DMI_BOARD_NAME, "N140CU"),
1220 		},
1221 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1222 	},
1223 	{
1224 		.matches = {
1225 			DMI_MATCH(DMI_BOARD_NAME, "N141CU"),
1226 		},
1227 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1228 	},
1229 	{
1230 		.matches = {
1231 			DMI_MATCH(DMI_BOARD_NAME, "N150CU"),
1232 		},
1233 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1234 	},
1235 	{
1236 		.matches = {
1237 			DMI_MATCH(DMI_BOARD_NAME, "NH5xAx"),
1238 		},
1239 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1240 	},
1241 	{
1242 		.matches = {
1243 			DMI_MATCH(DMI_BOARD_NAME, "NHxxRZQ"),
1244 		},
1245 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1246 	},
1247 	{
1248 		.matches = {
1249 			DMI_MATCH(DMI_BOARD_NAME, "NL5xRU"),
1250 		},
1251 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1252 	},
1253 	/*
1254 	 * At least one modern Clevo barebone has the touchpad connected both
1255 	 * via PS/2 and i2c interface. This causes a race condition between the
1256 	 * psmouse and i2c-hid driver. Since the full capability of the touchpad
1257 	 * is available via the i2c interface and the device has no external
1258 	 * PS/2 port, it is safe to just ignore all ps2 mouses here to avoid
1259 	 * this issue. The known affected device is the
1260 	 * TUXEDO InfinityBook S17 Gen6 / Clevo NS70MU which comes with one of
1261 	 * the two different dmi strings below. NS50MU is not a typo!
1262 	 */
1263 	{
1264 		.matches = {
1265 			DMI_MATCH(DMI_BOARD_NAME, "NS50MU"),
1266 		},
1267 		.driver_data = (void *)(SERIO_QUIRK_NOAUX |
1268 					SERIO_QUIRK_FORCENORESTORE)
1269 	},
1270 	{
1271 		.matches = {
1272 			DMI_MATCH(DMI_BOARD_NAME, "NS50_70MU"),
1273 		},
1274 		.driver_data = (void *)(SERIO_QUIRK_NOAUX |
1275 					SERIO_QUIRK_FORCENORESTORE)
1276 	},
1277 	{
1278 		.matches = {
1279 			DMI_MATCH(DMI_BOARD_NAME, "NS5x_7xPU"),
1280 		},
1281 		.driver_data = (void *)(SERIO_QUIRK_NOAUX)
1282 	},
1283 	{
1284 		.matches = {
1285 			DMI_MATCH(DMI_BOARD_NAME, "NJ50_70CU"),
1286 		},
1287 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1288 	},
1289 	{
1290 		.matches = {
1291 			DMI_MATCH(DMI_BOARD_NAME, "P640RE"),
1292 		},
1293 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1294 	},
1295 	{
1296 		/*
1297 		 * This is only a partial board_name and might be followed by
1298 		 * another letter or number. DMI_MATCH however does do partial
1299 		 * matching.
1300 		 */
1301 		.matches = {
1302 			DMI_MATCH(DMI_PRODUCT_NAME, "P65xH"),
1303 		},
1304 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1305 	},
1306 	{
1307 		/* Clevo P650RS, 650RP6, Sager NP8152-S, and others */
1308 		.matches = {
1309 			DMI_MATCH(DMI_PRODUCT_NAME, "P65xRP"),
1310 		},
1311 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1312 	},
1313 	{
1314 		/*
1315 		 * This is only a partial board_name and might be followed by
1316 		 * another letter or number. DMI_MATCH however does do partial
1317 		 * matching.
1318 		 */
1319 		.matches = {
1320 			DMI_MATCH(DMI_PRODUCT_NAME, "P65_P67H"),
1321 		},
1322 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1323 	},
1324 	{
1325 		/*
1326 		 * This is only a partial board_name and might be followed by
1327 		 * another letter or number. DMI_MATCH however does do partial
1328 		 * matching.
1329 		 */
1330 		.matches = {
1331 			DMI_MATCH(DMI_PRODUCT_NAME, "P65_67RP"),
1332 		},
1333 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1334 	},
1335 	{
1336 		/*
1337 		 * This is only a partial board_name and might be followed by
1338 		 * another letter or number. DMI_MATCH however does do partial
1339 		 * matching.
1340 		 */
1341 		.matches = {
1342 			DMI_MATCH(DMI_PRODUCT_NAME, "P65_67RS"),
1343 		},
1344 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1345 	},
1346 	{
1347 		/*
1348 		 * This is only a partial board_name and might be followed by
1349 		 * another letter or number. DMI_MATCH however does do partial
1350 		 * matching.
1351 		 */
1352 		.matches = {
1353 			DMI_MATCH(DMI_PRODUCT_NAME, "P67xRP"),
1354 		},
1355 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1356 	},
1357 	{
1358 		.matches = {
1359 			DMI_MATCH(DMI_BOARD_NAME, "PB50_70DFx,DDx"),
1360 		},
1361 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1362 	},
1363 	{
1364 		.matches = {
1365 			DMI_MATCH(DMI_BOARD_NAME, "PB51RF"),
1366 		},
1367 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1368 	},
1369 	{
1370 		.matches = {
1371 			DMI_MATCH(DMI_BOARD_NAME, "PB71RD"),
1372 		},
1373 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1374 	},
1375 	{
1376 		.matches = {
1377 			DMI_MATCH(DMI_BOARD_NAME, "PC70DR"),
1378 		},
1379 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1380 	},
1381 	{
1382 		.matches = {
1383 			DMI_MATCH(DMI_BOARD_NAME, "PCX0DX"),
1384 		},
1385 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1386 	},
1387 	{
1388 		.matches = {
1389 			DMI_MATCH(DMI_BOARD_NAME, "PCX0DX_GN20"),
1390 		},
1391 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1392 	},
1393 	/* See comment on TUXEDO InfinityBook S17 Gen6 / Clevo NS70MU above */
1394 	{
1395 		.matches = {
1396 			DMI_MATCH(DMI_BOARD_NAME, "PD5x_7xPNP_PNR_PNN_PNT"),
1397 		},
1398 		.driver_data = (void *)(SERIO_QUIRK_NOAUX)
1399 	},
1400 	{
1401 		.matches = {
1402 			DMI_MATCH(DMI_BOARD_NAME, "X170SM"),
1403 		},
1404 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1405 	},
1406 	{
1407 		.matches = {
1408 			DMI_MATCH(DMI_BOARD_NAME, "X170KM-G"),
1409 		},
1410 		.driver_data = (void *)(SERIO_QUIRK_FORCENORESTORE)
1411 	},
1412 	{
1413 		/*
1414 		 * The Ayaneo Kun is a handheld device where some the buttons
1415 		 * are handled by an AT keyboard. The keyboard is usually
1416 		 * detected as raw, but sometimes, usually after a cold boot,
1417 		 * it is detected as translated. Make sure that the keyboard
1418 		 * is always in raw mode.
1419 		 */
1420 		.matches = {
1421 			DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "AYANEO"),
1422 			DMI_MATCH(DMI_BOARD_NAME, "KUN"),
1423 		},
1424 		.driver_data = (void *)(SERIO_QUIRK_DIRECT)
1425 	},
1426 	{ }
1427 };
1428 
1429 #ifdef CONFIG_PNP
1430 static const struct dmi_system_id i8042_dmi_laptop_table[] __initconst = {
1431 	{
1432 		.matches = {
1433 			DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
1434 		},
1435 	},
1436 	{
1437 		.matches = {
1438 			DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /* Laptop */
1439 		},
1440 	},
1441 	{
1442 		.matches = {
1443 			DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
1444 		},
1445 	},
1446 	{
1447 		.matches = {
1448 			DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
1449 		},
1450 	},
1451 	{ }
1452 };
1453 #endif
1454 
1455 #endif /* CONFIG_X86 */
1456 
1457 #ifdef CONFIG_PNP
1458 #include <linux/pnp.h>
1459 
1460 static bool i8042_pnp_kbd_registered;
1461 static unsigned int i8042_pnp_kbd_devices;
1462 static bool i8042_pnp_aux_registered;
1463 static unsigned int i8042_pnp_aux_devices;
1464 
1465 static int i8042_pnp_command_reg;
1466 static int i8042_pnp_data_reg;
1467 static int i8042_pnp_kbd_irq;
1468 static int i8042_pnp_aux_irq;
1469 
1470 static char i8042_pnp_kbd_name[32];
1471 static char i8042_pnp_aux_name[32];
1472 
i8042_pnp_id_to_string(struct pnp_id * id,char * dst,int dst_size)1473 static void i8042_pnp_id_to_string(struct pnp_id *id, char *dst, int dst_size)
1474 {
1475 	strscpy(dst, "PNP:", dst_size);
1476 
1477 	while (id) {
1478 		strlcat(dst, " ", dst_size);
1479 		strlcat(dst, id->id, dst_size);
1480 		id = id->next;
1481 	}
1482 }
1483 
i8042_pnp_kbd_probe(struct pnp_dev * dev,const struct pnp_device_id * did)1484 static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
1485 {
1486 	if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
1487 		i8042_pnp_data_reg = pnp_port_start(dev,0);
1488 
1489 	if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
1490 		i8042_pnp_command_reg = pnp_port_start(dev, 1);
1491 
1492 	if (pnp_irq_valid(dev,0))
1493 		i8042_pnp_kbd_irq = pnp_irq(dev, 0);
1494 
1495 	strscpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
1496 	if (strlen(pnp_dev_name(dev))) {
1497 		strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
1498 		strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
1499 	}
1500 	i8042_pnp_id_to_string(dev->id, i8042_kbd_firmware_id,
1501 			       sizeof(i8042_kbd_firmware_id));
1502 	i8042_kbd_fwnode = dev_fwnode(&dev->dev);
1503 
1504 	/* Keyboard ports are always supposed to be wakeup-enabled */
1505 	device_set_wakeup_enable(&dev->dev, true);
1506 
1507 	i8042_pnp_kbd_devices++;
1508 	return 0;
1509 }
1510 
i8042_pnp_aux_probe(struct pnp_dev * dev,const struct pnp_device_id * did)1511 static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
1512 {
1513 	if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
1514 		i8042_pnp_data_reg = pnp_port_start(dev,0);
1515 
1516 	if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
1517 		i8042_pnp_command_reg = pnp_port_start(dev, 1);
1518 
1519 	if (pnp_irq_valid(dev, 0))
1520 		i8042_pnp_aux_irq = pnp_irq(dev, 0);
1521 
1522 	strscpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
1523 	if (strlen(pnp_dev_name(dev))) {
1524 		strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
1525 		strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
1526 	}
1527 	i8042_pnp_id_to_string(dev->id, i8042_aux_firmware_id,
1528 			       sizeof(i8042_aux_firmware_id));
1529 
1530 	i8042_pnp_aux_devices++;
1531 	return 0;
1532 }
1533 
1534 static const struct pnp_device_id pnp_kbd_devids[] = {
1535 	{ .id = "PNP0300", .driver_data = 0 },
1536 	{ .id = "PNP0301", .driver_data = 0 },
1537 	{ .id = "PNP0302", .driver_data = 0 },
1538 	{ .id = "PNP0303", .driver_data = 0 },
1539 	{ .id = "PNP0304", .driver_data = 0 },
1540 	{ .id = "PNP0305", .driver_data = 0 },
1541 	{ .id = "PNP0306", .driver_data = 0 },
1542 	{ .id = "PNP0309", .driver_data = 0 },
1543 	{ .id = "PNP030a", .driver_data = 0 },
1544 	{ .id = "PNP030b", .driver_data = 0 },
1545 	{ .id = "PNP0320", .driver_data = 0 },
1546 	{ .id = "PNP0343", .driver_data = 0 },
1547 	{ .id = "PNP0344", .driver_data = 0 },
1548 	{ .id = "PNP0345", .driver_data = 0 },
1549 	{ .id = "CPQA0D7", .driver_data = 0 },
1550 	{ .id = "", },
1551 };
1552 MODULE_DEVICE_TABLE(pnp, pnp_kbd_devids);
1553 
1554 static struct pnp_driver i8042_pnp_kbd_driver = {
1555 	.name           = "i8042 kbd",
1556 	.id_table       = pnp_kbd_devids,
1557 	.probe          = i8042_pnp_kbd_probe,
1558 	.driver         = {
1559 		.probe_type = PROBE_FORCE_SYNCHRONOUS,
1560 		.suppress_bind_attrs = true,
1561 	},
1562 };
1563 
1564 static const struct pnp_device_id pnp_aux_devids[] = {
1565 	{ .id = "AUI0200", .driver_data = 0 },
1566 	{ .id = "FJC6000", .driver_data = 0 },
1567 	{ .id = "FJC6001", .driver_data = 0 },
1568 	{ .id = "PNP0f03", .driver_data = 0 },
1569 	{ .id = "PNP0f0b", .driver_data = 0 },
1570 	{ .id = "PNP0f0e", .driver_data = 0 },
1571 	{ .id = "PNP0f12", .driver_data = 0 },
1572 	{ .id = "PNP0f13", .driver_data = 0 },
1573 	{ .id = "PNP0f19", .driver_data = 0 },
1574 	{ .id = "PNP0f1c", .driver_data = 0 },
1575 	{ .id = "SYN0801", .driver_data = 0 },
1576 	{ .id = "", },
1577 };
1578 MODULE_DEVICE_TABLE(pnp, pnp_aux_devids);
1579 
1580 static struct pnp_driver i8042_pnp_aux_driver = {
1581 	.name           = "i8042 aux",
1582 	.id_table       = pnp_aux_devids,
1583 	.probe          = i8042_pnp_aux_probe,
1584 	.driver         = {
1585 		.probe_type = PROBE_FORCE_SYNCHRONOUS,
1586 		.suppress_bind_attrs = true,
1587 	},
1588 };
1589 
i8042_pnp_exit(void)1590 static void i8042_pnp_exit(void)
1591 {
1592 	if (i8042_pnp_kbd_registered) {
1593 		i8042_pnp_kbd_registered = false;
1594 		pnp_unregister_driver(&i8042_pnp_kbd_driver);
1595 	}
1596 
1597 	if (i8042_pnp_aux_registered) {
1598 		i8042_pnp_aux_registered = false;
1599 		pnp_unregister_driver(&i8042_pnp_aux_driver);
1600 	}
1601 }
1602 
i8042_pnp_init(void)1603 static int __init i8042_pnp_init(void)
1604 {
1605 	char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
1606 	bool pnp_data_busted = false;
1607 	int err;
1608 
1609 	if (i8042_nopnp) {
1610 		pr_info("PNP detection disabled\n");
1611 		return 0;
1612 	}
1613 
1614 	err = pnp_register_driver(&i8042_pnp_kbd_driver);
1615 	if (!err)
1616 		i8042_pnp_kbd_registered = true;
1617 
1618 	err = pnp_register_driver(&i8042_pnp_aux_driver);
1619 	if (!err)
1620 		i8042_pnp_aux_registered = true;
1621 
1622 	if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
1623 		i8042_pnp_exit();
1624 #if defined(__ia64__)
1625 		return -ENODEV;
1626 #else
1627 		pr_info("PNP: No PS/2 controller found.\n");
1628 #if defined(__loongarch__)
1629 		if (acpi_disabled == 0)
1630 			return -ENODEV;
1631 #else
1632 		if (x86_platform.legacy.i8042 !=
1633 				X86_LEGACY_I8042_EXPECTED_PRESENT)
1634 			return -ENODEV;
1635 #endif
1636 		pr_info("Probing ports directly.\n");
1637 		return 0;
1638 #endif
1639 	}
1640 
1641 	if (i8042_pnp_kbd_devices)
1642 		snprintf(kbd_irq_str, sizeof(kbd_irq_str),
1643 			"%d", i8042_pnp_kbd_irq);
1644 	if (i8042_pnp_aux_devices)
1645 		snprintf(aux_irq_str, sizeof(aux_irq_str),
1646 			"%d", i8042_pnp_aux_irq);
1647 
1648 	pr_info("PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
1649 		i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
1650 		i8042_pnp_aux_name,
1651 		i8042_pnp_data_reg, i8042_pnp_command_reg,
1652 		kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
1653 		aux_irq_str);
1654 
1655 #if defined(__ia64__)
1656 	if (!i8042_pnp_kbd_devices)
1657 		i8042_nokbd = true;
1658 	if (!i8042_pnp_aux_devices)
1659 		i8042_noaux = true;
1660 #endif
1661 
1662 	if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
1663 	      i8042_pnp_data_reg != i8042_data_reg) ||
1664 	    !i8042_pnp_data_reg) {
1665 		pr_warn("PNP: PS/2 controller has invalid data port %#x; using default %#x\n",
1666 			i8042_pnp_data_reg, i8042_data_reg);
1667 		i8042_pnp_data_reg = i8042_data_reg;
1668 		pnp_data_busted = true;
1669 	}
1670 
1671 	if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
1672 	      i8042_pnp_command_reg != i8042_command_reg) ||
1673 	    !i8042_pnp_command_reg) {
1674 		pr_warn("PNP: PS/2 controller has invalid command port %#x; using default %#x\n",
1675 			i8042_pnp_command_reg, i8042_command_reg);
1676 		i8042_pnp_command_reg = i8042_command_reg;
1677 		pnp_data_busted = true;
1678 	}
1679 
1680 	if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
1681 		pr_warn("PNP: PS/2 controller doesn't have KBD irq; using default %d\n",
1682 			i8042_kbd_irq);
1683 		i8042_pnp_kbd_irq = i8042_kbd_irq;
1684 		pnp_data_busted = true;
1685 	}
1686 
1687 	if (!i8042_noaux && !i8042_pnp_aux_irq) {
1688 		if (!pnp_data_busted && i8042_pnp_kbd_irq) {
1689 			pr_warn("PNP: PS/2 appears to have AUX port disabled, "
1690 				"if this is incorrect please boot with i8042.nopnp\n");
1691 			i8042_noaux = true;
1692 		} else {
1693 			pr_warn("PNP: PS/2 controller doesn't have AUX irq; using default %d\n",
1694 				i8042_aux_irq);
1695 			i8042_pnp_aux_irq = i8042_aux_irq;
1696 		}
1697 	}
1698 
1699 	i8042_data_reg = i8042_pnp_data_reg;
1700 	i8042_command_reg = i8042_pnp_command_reg;
1701 	i8042_kbd_irq = i8042_pnp_kbd_irq;
1702 	i8042_aux_irq = i8042_pnp_aux_irq;
1703 
1704 #ifdef CONFIG_X86
1705 	i8042_bypass_aux_irq_test = !pnp_data_busted &&
1706 				    dmi_check_system(i8042_dmi_laptop_table);
1707 #endif
1708 
1709 	return 0;
1710 }
1711 
1712 #else  /* !CONFIG_PNP */
i8042_pnp_init(void)1713 static inline int i8042_pnp_init(void) { return 0; }
i8042_pnp_exit(void)1714 static inline void i8042_pnp_exit(void) { }
1715 #endif /* CONFIG_PNP */
1716 
1717 
1718 #ifdef CONFIG_X86
i8042_check_quirks(void)1719 static void __init i8042_check_quirks(void)
1720 {
1721 	const struct dmi_system_id *device_quirk_info;
1722 	uintptr_t quirks;
1723 
1724 	device_quirk_info = dmi_first_match(i8042_dmi_quirk_table);
1725 	if (!device_quirk_info)
1726 		return;
1727 
1728 	quirks = (uintptr_t)device_quirk_info->driver_data;
1729 
1730 	if (quirks & SERIO_QUIRK_NOKBD)
1731 		i8042_nokbd = true;
1732 	if (quirks & SERIO_QUIRK_NOAUX)
1733 		i8042_noaux = true;
1734 	if (quirks & SERIO_QUIRK_NOMUX)
1735 		i8042_nomux = true;
1736 	if (quirks & SERIO_QUIRK_FORCEMUX)
1737 		i8042_nomux = false;
1738 	if (quirks & SERIO_QUIRK_UNLOCK)
1739 		i8042_unlock = true;
1740 	if (quirks & SERIO_QUIRK_PROBE_DEFER)
1741 		i8042_probe_defer = true;
1742 	/* Honor module parameter when value is not default */
1743 	if (i8042_reset == I8042_RESET_DEFAULT) {
1744 		if (quirks & SERIO_QUIRK_RESET_ALWAYS)
1745 			i8042_reset = I8042_RESET_ALWAYS;
1746 		if (quirks & SERIO_QUIRK_RESET_NEVER)
1747 			i8042_reset = I8042_RESET_NEVER;
1748 	}
1749 	if (quirks & SERIO_QUIRK_DIRECT)
1750 		i8042_direct = true;
1751 	if (quirks & SERIO_QUIRK_DUMBKBD)
1752 		i8042_dumbkbd = true;
1753 	if (quirks & SERIO_QUIRK_NOLOOP)
1754 		i8042_noloop = true;
1755 	if (quirks & SERIO_QUIRK_NOTIMEOUT)
1756 		i8042_notimeout = true;
1757 	if (quirks & SERIO_QUIRK_KBDRESET)
1758 		i8042_kbdreset = true;
1759 	if (quirks & SERIO_QUIRK_DRITEK)
1760 		i8042_dritek = true;
1761 #ifdef CONFIG_PNP
1762 	if (quirks & SERIO_QUIRK_NOPNP)
1763 		i8042_nopnp = true;
1764 #endif
1765 	if (quirks & SERIO_QUIRK_FORCENORESTORE)
1766 		i8042_forcenorestore = true;
1767 }
1768 #else
i8042_check_quirks(void)1769 static inline void i8042_check_quirks(void) {}
1770 #endif
1771 
i8042_platform_init(void)1772 static int __init i8042_platform_init(void)
1773 {
1774 	int retval;
1775 
1776 #ifdef CONFIG_X86
1777 	u8 a20_on = 0xdf;
1778 	/* Just return if platform does not have i8042 controller */
1779 	if (x86_platform.legacy.i8042 == X86_LEGACY_I8042_PLATFORM_ABSENT)
1780 		return -ENODEV;
1781 #endif
1782 
1783 /*
1784  * On ix86 platforms touching the i8042 data register region can do really
1785  * bad things. Because of this the region is always reserved on ix86 boxes.
1786  *
1787  *	if (!request_region(I8042_DATA_REG, 16, "i8042"))
1788  *		return -EBUSY;
1789  */
1790 
1791 	i8042_kbd_irq = I8042_MAP_IRQ(1);
1792 	i8042_aux_irq = I8042_MAP_IRQ(12);
1793 
1794 #if defined(__ia64__)
1795 	i8042_reset = I8042_RESET_ALWAYS;
1796 #endif
1797 
1798 	i8042_check_quirks();
1799 
1800 	pr_debug("Active quirks (empty means none):%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
1801 		i8042_nokbd ? " nokbd" : "",
1802 		i8042_noaux ? " noaux" : "",
1803 		i8042_nomux ? " nomux" : "",
1804 		i8042_unlock ? " unlock" : "",
1805 		i8042_probe_defer ? "probe_defer" : "",
1806 		i8042_reset == I8042_RESET_DEFAULT ?
1807 			"" : i8042_reset == I8042_RESET_ALWAYS ?
1808 				" reset_always" : " reset_never",
1809 		i8042_direct ? " direct" : "",
1810 		i8042_dumbkbd ? " dumbkbd" : "",
1811 		i8042_noloop ? " noloop" : "",
1812 		i8042_notimeout ? " notimeout" : "",
1813 		i8042_kbdreset ? " kbdreset" : "",
1814 #ifdef CONFIG_X86
1815 		i8042_dritek ? " dritek" : "",
1816 #else
1817 		"",
1818 #endif
1819 #ifdef CONFIG_PNP
1820 		i8042_nopnp ? " nopnp" : "",
1821 #else
1822 		"",
1823 #endif
1824 		i8042_forcenorestore ? " forcenorestore" : "");
1825 
1826 	retval = i8042_pnp_init();
1827 	if (retval)
1828 		return retval;
1829 
1830 #ifdef CONFIG_X86
1831 	/*
1832 	 * A20 was already enabled during early kernel init. But some buggy
1833 	 * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
1834 	 * resume from S3. So we do it here and hope that nothing breaks.
1835 	 */
1836 	i8042_command(&a20_on, 0x10d1);
1837 	i8042_command(NULL, 0x00ff);	/* Null command for SMM firmware */
1838 #endif /* CONFIG_X86 */
1839 
1840 	return retval;
1841 }
1842 
i8042_platform_exit(void)1843 static inline void i8042_platform_exit(void)
1844 {
1845 	i8042_pnp_exit();
1846 }
1847 
1848 #endif /* _I8042_ACPIPNPIO_H */
1849