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