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