1 #ifndef _I8042_X86IA64IO_H
2 #define _I8042_X86IA64IO_H
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
11 #include <asm/x86_init.h>
18 #define I8042_KBD_PHYS_DESC "isa0060/serio0"
19 #define I8042_AUX_PHYS_DESC "isa0060/serio1"
20 #define I8042_MUX_PHYS_DESC "isa0060/serio%d"
27 # define I8042_MAP_IRQ(x) isa_irq_to_vector((x))
29 # define I8042_MAP_IRQ(x) (x)
32 #define I8042_KBD_IRQ i8042_kbd_irq
33 #define I8042_AUX_IRQ i8042_aux_irq
35 static int i8042_kbd_irq;
36 static int i8042_aux_irq;
42 #define I8042_COMMAND_REG i8042_command_reg
43 #define I8042_STATUS_REG i8042_command_reg
44 #define I8042_DATA_REG i8042_data_reg
46 static int i8042_command_reg = 0x64;
47 static int i8042_data_reg = 0x60;
50 static inline int i8042_read_data(void)
52 return inb(I8042_DATA_REG);
55 static inline int i8042_read_status(void)
57 return inb(I8042_STATUS_REG);
60 static inline void i8042_write_data(int val)
62 outb(val, I8042_DATA_REG);
65 static inline void i8042_write_command(int val)
67 outb(val, I8042_COMMAND_REG);
72 #include <linux/dmi.h>
74 static const struct dmi_system_id __initconst i8042_dmi_noloop_table[] = {
77 * Arima-Rioworks HDAMB -
78 * AUX LOOP command does not raise AUX IRQ
81 DMI_MATCH(DMI_BOARD_VENDOR, "RIOWORKS"),
82 DMI_MATCH(DMI_BOARD_NAME, "HDAMB"),
83 DMI_MATCH(DMI_BOARD_VERSION, "Rev E"),
89 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."),
90 DMI_MATCH(DMI_BOARD_NAME, "G1S"),
91 DMI_MATCH(DMI_BOARD_VERSION, "1.0"),
95 /* ASUS P65UP5 - AUX LOOP command does not raise AUX IRQ */
97 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
98 DMI_MATCH(DMI_BOARD_NAME, "P/I-P65UP5"),
99 DMI_MATCH(DMI_BOARD_VERSION, "REV 2.X"),
104 DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
105 DMI_MATCH(DMI_PRODUCT_NAME, "X750LN"),
110 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
111 DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
112 DMI_MATCH(DMI_PRODUCT_VERSION, "8500"),
117 DMI_MATCH(DMI_SYS_VENDOR, "Compaq"),
118 DMI_MATCH(DMI_PRODUCT_NAME , "ProLiant"),
119 DMI_MATCH(DMI_PRODUCT_VERSION, "DL760"),
125 DMI_MATCH(DMI_SYS_VENDOR, "OQO"),
126 DMI_MATCH(DMI_PRODUCT_NAME, "ZEPTO"),
127 DMI_MATCH(DMI_PRODUCT_VERSION, "00"),
131 /* ULI EV4873 - AUX LOOP does not work properly */
133 DMI_MATCH(DMI_SYS_VENDOR, "ULI"),
134 DMI_MATCH(DMI_PRODUCT_NAME, "EV4873"),
135 DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
139 /* Microsoft Virtual Machine */
141 DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
142 DMI_MATCH(DMI_PRODUCT_NAME, "Virtual Machine"),
143 DMI_MATCH(DMI_PRODUCT_VERSION, "VS2005R2"),
147 /* Medion MAM 2070 */
149 DMI_MATCH(DMI_SYS_VENDOR, "Notebook"),
150 DMI_MATCH(DMI_PRODUCT_NAME, "MAM 2070"),
151 DMI_MATCH(DMI_PRODUCT_VERSION, "5a"),
157 DMI_MATCH(DMI_SYS_VENDOR, "blue"),
158 DMI_MATCH(DMI_PRODUCT_NAME, "FB5601"),
159 DMI_MATCH(DMI_PRODUCT_VERSION, "M606"),
165 DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
166 DMI_MATCH(DMI_PRODUCT_NAME, "M912"),
167 DMI_MATCH(DMI_PRODUCT_VERSION, "01"),
171 /* Gigabyte M1022M netbook */
173 DMI_MATCH(DMI_BOARD_VENDOR, "Gigabyte Technology Co.,Ltd."),
174 DMI_MATCH(DMI_BOARD_NAME, "M1022E"),
175 DMI_MATCH(DMI_BOARD_VERSION, "1.02"),
179 /* Gigabyte Spring Peak - defines wrong chassis type */
181 DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
182 DMI_MATCH(DMI_PRODUCT_NAME, "Spring Peak"),
186 /* Gigabyte T1005 - defines wrong chassis type ("Other") */
188 DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
189 DMI_MATCH(DMI_PRODUCT_NAME, "T1005"),
193 /* Gigabyte T1005M/P - defines wrong chassis type ("Other") */
195 DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
196 DMI_MATCH(DMI_PRODUCT_NAME, "T1005M/P"),
201 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
202 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv9700"),
203 DMI_MATCH(DMI_PRODUCT_VERSION, "Rev 1"),
210 * Some laptops do implement active multiplexing mode correctly;
211 * unfortunately they are in minority.
213 static const struct dmi_system_id __initconst i8042_dmi_mux_table[] = {
216 * Panasonic CF-18 needs to be in MUX mode since the
217 * touchscreen is on serio3 and it also has touchpad.
220 DMI_MATCH(DMI_PRODUCT_NAME, "CF-18"),
226 static const struct dmi_system_id __initconst i8042_dmi_reset_table[] = {
230 DMI_MATCH(DMI_BOARD_NAME, "U-100"),
231 DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
235 /* LG Electronics X110 */
237 DMI_MATCH(DMI_BOARD_NAME, "X110"),
238 DMI_MATCH(DMI_BOARD_VENDOR, "LG Electronics Inc."),
242 /* Acer Aspire One 150 */
244 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
245 DMI_MATCH(DMI_PRODUCT_NAME, "AOA150"),
251 DMI_MATCH(DMI_SYS_VENDOR, "DIXONSXP"),
252 DMI_MATCH(DMI_PRODUCT_NAME, "Advent 4211"),
256 /* Medion Akoya Mini E1210 */
258 DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
259 DMI_MATCH(DMI_PRODUCT_NAME, "E1210"),
263 /* Medion Akoya E1222 */
265 DMI_MATCH(DMI_SYS_VENDOR, "MEDION"),
266 DMI_MATCH(DMI_PRODUCT_NAME, "E122X"),
272 DMI_MATCH(DMI_SYS_VENDOR, "VIOOO"),
273 DMI_MATCH(DMI_PRODUCT_NAME, "N10"),
277 /* Dell Vostro 1320 */
279 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
280 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1320"),
284 /* Dell Vostro 1520 */
286 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
287 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1520"),
291 /* Dell Vostro 1720 */
293 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
294 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro 1720"),
298 /* Lenovo Ideapad U455 */
300 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
301 DMI_MATCH(DMI_PRODUCT_NAME, "20046"),
308 static const struct dmi_system_id __initconst i8042_dmi_nopnp_table[] = {
310 /* Intel MBO Desktop D845PESV */
312 DMI_MATCH(DMI_BOARD_NAME, "D845PESV"),
313 DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
319 DMI_MATCH(DMI_BOARD_NAME, "U-100"),
320 DMI_MATCH(DMI_BOARD_VENDOR, "MICRO-STAR INTERNATIONAL CO., LTD"),
326 static const struct dmi_system_id __initconst i8042_dmi_laptop_table[] = {
329 DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */
334 DMI_MATCH(DMI_CHASSIS_TYPE, "9"), /* Laptop */
339 DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */
344 DMI_MATCH(DMI_CHASSIS_TYPE, "14"), /* Sub-Notebook */
351 static const struct dmi_system_id __initconst i8042_dmi_notimeout_table[] = {
353 /* Dell Vostro V13 */
355 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
356 DMI_MATCH(DMI_PRODUCT_NAME, "Vostro V13"),
360 /* Newer HP Pavilion dv4 models */
362 DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
363 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"),
367 /* Fujitsu U574 laptop */
368 /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */
370 DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"),
371 DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U574"),
378 * Some Wistron based laptops need us to explicitly enable the 'Dritek
379 * keyboard extension' to make their extra keys start generating scancodes.
380 * Originally, this was just confined to older laptops, but a few Acer laptops
381 * have turned up in 2007 that also need this again.
383 static const struct dmi_system_id __initconst i8042_dmi_dritek_table[] = {
385 /* Acer Aspire 5100 */
387 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
388 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5100"),
392 /* Acer Aspire 5610 */
394 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
395 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5610"),
399 /* Acer Aspire 5630 */
401 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
402 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5630"),
406 /* Acer Aspire 5650 */
408 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
409 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5650"),
413 /* Acer Aspire 5680 */
415 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
416 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5680"),
420 /* Acer Aspire 5720 */
422 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
423 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5720"),
427 /* Acer Aspire 9110 */
429 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
430 DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 9110"),
434 /* Acer TravelMate 660 */
436 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
437 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 660"),
441 /* Acer TravelMate 2490 */
443 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
444 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 2490"),
448 /* Acer TravelMate 4280 */
450 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
451 DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate 4280"),
457 #endif /* CONFIG_X86 */
460 #include <linux/pnp.h>
462 static bool i8042_pnp_kbd_registered;
463 static unsigned int i8042_pnp_kbd_devices;
464 static bool i8042_pnp_aux_registered;
465 static unsigned int i8042_pnp_aux_devices;
467 static int i8042_pnp_command_reg;
468 static int i8042_pnp_data_reg;
469 static int i8042_pnp_kbd_irq;
470 static int i8042_pnp_aux_irq;
472 static char i8042_pnp_kbd_name[32];
473 static char i8042_pnp_aux_name[32];
475 static void i8042_pnp_id_to_string(struct pnp_id *id, char *dst, int dst_size)
477 strlcpy(dst, "PNP:", dst_size);
480 strlcat(dst, " ", dst_size);
481 strlcat(dst, id->id, dst_size);
486 static int i8042_pnp_kbd_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
488 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
489 i8042_pnp_data_reg = pnp_port_start(dev,0);
491 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
492 i8042_pnp_command_reg = pnp_port_start(dev, 1);
494 if (pnp_irq_valid(dev,0))
495 i8042_pnp_kbd_irq = pnp_irq(dev, 0);
497 strlcpy(i8042_pnp_kbd_name, did->id, sizeof(i8042_pnp_kbd_name));
498 if (strlen(pnp_dev_name(dev))) {
499 strlcat(i8042_pnp_kbd_name, ":", sizeof(i8042_pnp_kbd_name));
500 strlcat(i8042_pnp_kbd_name, pnp_dev_name(dev), sizeof(i8042_pnp_kbd_name));
502 i8042_pnp_id_to_string(dev->id, i8042_kbd_firmware_id,
503 sizeof(i8042_kbd_firmware_id));
505 /* Keyboard ports are always supposed to be wakeup-enabled */
506 device_set_wakeup_enable(&dev->dev, true);
508 i8042_pnp_kbd_devices++;
512 static int i8042_pnp_aux_probe(struct pnp_dev *dev, const struct pnp_device_id *did)
514 if (pnp_port_valid(dev, 0) && pnp_port_len(dev, 0) == 1)
515 i8042_pnp_data_reg = pnp_port_start(dev,0);
517 if (pnp_port_valid(dev, 1) && pnp_port_len(dev, 1) == 1)
518 i8042_pnp_command_reg = pnp_port_start(dev, 1);
520 if (pnp_irq_valid(dev, 0))
521 i8042_pnp_aux_irq = pnp_irq(dev, 0);
523 strlcpy(i8042_pnp_aux_name, did->id, sizeof(i8042_pnp_aux_name));
524 if (strlen(pnp_dev_name(dev))) {
525 strlcat(i8042_pnp_aux_name, ":", sizeof(i8042_pnp_aux_name));
526 strlcat(i8042_pnp_aux_name, pnp_dev_name(dev), sizeof(i8042_pnp_aux_name));
528 i8042_pnp_id_to_string(dev->id, i8042_aux_firmware_id,
529 sizeof(i8042_aux_firmware_id));
531 i8042_pnp_aux_devices++;
535 static struct pnp_device_id pnp_kbd_devids[] = {
536 { .id = "PNP0300", .driver_data = 0 },
537 { .id = "PNP0301", .driver_data = 0 },
538 { .id = "PNP0302", .driver_data = 0 },
539 { .id = "PNP0303", .driver_data = 0 },
540 { .id = "PNP0304", .driver_data = 0 },
541 { .id = "PNP0305", .driver_data = 0 },
542 { .id = "PNP0306", .driver_data = 0 },
543 { .id = "PNP0309", .driver_data = 0 },
544 { .id = "PNP030a", .driver_data = 0 },
545 { .id = "PNP030b", .driver_data = 0 },
546 { .id = "PNP0320", .driver_data = 0 },
547 { .id = "PNP0343", .driver_data = 0 },
548 { .id = "PNP0344", .driver_data = 0 },
549 { .id = "PNP0345", .driver_data = 0 },
550 { .id = "CPQA0D7", .driver_data = 0 },
553 MODULE_DEVICE_TABLE(pnp, pnp_kbd_devids);
555 static struct pnp_driver i8042_pnp_kbd_driver = {
557 .id_table = pnp_kbd_devids,
558 .probe = i8042_pnp_kbd_probe,
561 static struct pnp_device_id pnp_aux_devids[] = {
562 { .id = "AUI0200", .driver_data = 0 },
563 { .id = "FJC6000", .driver_data = 0 },
564 { .id = "FJC6001", .driver_data = 0 },
565 { .id = "PNP0f03", .driver_data = 0 },
566 { .id = "PNP0f0b", .driver_data = 0 },
567 { .id = "PNP0f0e", .driver_data = 0 },
568 { .id = "PNP0f12", .driver_data = 0 },
569 { .id = "PNP0f13", .driver_data = 0 },
570 { .id = "PNP0f19", .driver_data = 0 },
571 { .id = "PNP0f1c", .driver_data = 0 },
572 { .id = "SYN0801", .driver_data = 0 },
575 MODULE_DEVICE_TABLE(pnp, pnp_aux_devids);
577 static struct pnp_driver i8042_pnp_aux_driver = {
579 .id_table = pnp_aux_devids,
580 .probe = i8042_pnp_aux_probe,
583 static void i8042_pnp_exit(void)
585 if (i8042_pnp_kbd_registered) {
586 i8042_pnp_kbd_registered = false;
587 pnp_unregister_driver(&i8042_pnp_kbd_driver);
590 if (i8042_pnp_aux_registered) {
591 i8042_pnp_aux_registered = false;
592 pnp_unregister_driver(&i8042_pnp_aux_driver);
596 static int __init i8042_pnp_init(void)
598 char kbd_irq_str[4] = { 0 }, aux_irq_str[4] = { 0 };
599 bool pnp_data_busted = false;
603 if (dmi_check_system(i8042_dmi_nopnp_table))
608 pr_info("PNP detection disabled\n");
612 err = pnp_register_driver(&i8042_pnp_kbd_driver);
614 i8042_pnp_kbd_registered = true;
616 err = pnp_register_driver(&i8042_pnp_aux_driver);
618 i8042_pnp_aux_registered = true;
620 if (!i8042_pnp_kbd_devices && !i8042_pnp_aux_devices) {
622 #if defined(__ia64__)
625 pr_info("PNP: No PS/2 controller found. Probing ports directly.\n");
630 if (i8042_pnp_kbd_devices)
631 snprintf(kbd_irq_str, sizeof(kbd_irq_str),
632 "%d", i8042_pnp_kbd_irq);
633 if (i8042_pnp_aux_devices)
634 snprintf(aux_irq_str, sizeof(aux_irq_str),
635 "%d", i8042_pnp_aux_irq);
637 pr_info("PNP: PS/2 Controller [%s%s%s] at %#x,%#x irq %s%s%s\n",
638 i8042_pnp_kbd_name, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
640 i8042_pnp_data_reg, i8042_pnp_command_reg,
641 kbd_irq_str, (i8042_pnp_kbd_devices && i8042_pnp_aux_devices) ? "," : "",
644 #if defined(__ia64__)
645 if (!i8042_pnp_kbd_devices)
647 if (!i8042_pnp_aux_devices)
651 if (((i8042_pnp_data_reg & ~0xf) == (i8042_data_reg & ~0xf) &&
652 i8042_pnp_data_reg != i8042_data_reg) ||
653 !i8042_pnp_data_reg) {
654 pr_warn("PNP: PS/2 controller has invalid data port %#x; using default %#x\n",
655 i8042_pnp_data_reg, i8042_data_reg);
656 i8042_pnp_data_reg = i8042_data_reg;
657 pnp_data_busted = true;
660 if (((i8042_pnp_command_reg & ~0xf) == (i8042_command_reg & ~0xf) &&
661 i8042_pnp_command_reg != i8042_command_reg) ||
662 !i8042_pnp_command_reg) {
663 pr_warn("PNP: PS/2 controller has invalid command port %#x; using default %#x\n",
664 i8042_pnp_command_reg, i8042_command_reg);
665 i8042_pnp_command_reg = i8042_command_reg;
666 pnp_data_busted = true;
669 if (!i8042_nokbd && !i8042_pnp_kbd_irq) {
670 pr_warn("PNP: PS/2 controller doesn't have KBD irq; using default %d\n",
672 i8042_pnp_kbd_irq = i8042_kbd_irq;
673 pnp_data_busted = true;
676 if (!i8042_noaux && !i8042_pnp_aux_irq) {
677 if (!pnp_data_busted && i8042_pnp_kbd_irq) {
678 pr_warn("PNP: PS/2 appears to have AUX port disabled, "
679 "if this is incorrect please boot with i8042.nopnp\n");
682 pr_warn("PNP: PS/2 controller doesn't have AUX irq; using default %d\n",
684 i8042_pnp_aux_irq = i8042_aux_irq;
688 i8042_data_reg = i8042_pnp_data_reg;
689 i8042_command_reg = i8042_pnp_command_reg;
690 i8042_kbd_irq = i8042_pnp_kbd_irq;
691 i8042_aux_irq = i8042_pnp_aux_irq;
694 i8042_bypass_aux_irq_test = !pnp_data_busted &&
695 dmi_check_system(i8042_dmi_laptop_table);
702 static inline int i8042_pnp_init(void) { return 0; }
703 static inline void i8042_pnp_exit(void) { }
706 static int __init i8042_platform_init(void)
712 /* Just return if pre-detection shows no i8042 controller exist */
713 if (!x86_platform.i8042_detect())
718 * On ix86 platforms touching the i8042 data register region can do really
719 * bad things. Because of this the region is always reserved on ix86 boxes.
721 * if (!request_region(I8042_DATA_REG, 16, "i8042"))
725 i8042_kbd_irq = I8042_MAP_IRQ(1);
726 i8042_aux_irq = I8042_MAP_IRQ(12);
728 retval = i8042_pnp_init();
732 #if defined(__ia64__)
737 if (dmi_check_system(i8042_dmi_reset_table))
740 if (dmi_check_system(i8042_dmi_noloop_table))
743 if (dmi_check_system(i8042_dmi_mux_table))
746 if (dmi_check_system(i8042_dmi_notimeout_table))
747 i8042_notimeout = true;
749 if (dmi_check_system(i8042_dmi_dritek_table))
753 * A20 was already enabled during early kernel init. But some buggy
754 * BIOSes (in MSI Laptops) require A20 to be enabled using 8042 to
755 * resume from S3. So we do it here and hope that nothing breaks.
757 i8042_command(&a20_on, 0x10d1);
758 i8042_command(NULL, 0x00ff); /* Null command for SMM firmware */
759 #endif /* CONFIG_X86 */
764 static inline void i8042_platform_exit(void)
769 #endif /* _I8042_X86IA64IO_H */