Lines Matching +full:keyboard +full:- +full:controller
1 // SPDX-License-Identifier: GPL-2.0-only
3 * i8042 keyboard and mouse controller driver for Linux
5 * Copyright (c) 1999-2004 Vojtech Pavlik
29 MODULE_DESCRIPTION("i8042 keyboard and mouse controller driver");
42 MODULE_PARM_DESC(nomux, "Do not check whether an active multiplexing controller is present.");
46 MODULE_PARM_DESC(unlock, "Ignore keyboard lock.");
61 enum i8042_controller_reset_mode *arg = kp->arg; in i8042_set_reset()
84 MODULE_PARM_DESC(reset, "Reset controller on resume, cleanup or both");
88 MODULE_PARM_DESC(direct, "Put keyboard port into non-translated mode.");
92 MODULE_PARM_DESC(dumbkbd, "Pretend that controller can only read data from keyboard");
109 MODULE_PARM_DESC(dritek, "Force enable the Dritek keyboard extension");
115 MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings");
130 …enable (may reveal sensitive data) of normally sanitize-filtered kbd data traffic debug log [pre-c…
202 return -EBUSY; in i8042_install_filter()
215 return -EINVAL; in i8042_remove_filter()
237 return -(i == I8042_CTL_TIMEOUT); in i8042_wait_read()
248 return -(i == I8042_CTL_TIMEOUT); in i8042_wait_write()
252 * i8042_flush() flushes all data that may be in the keyboard and mouse buffers
265 return -EIO; in i8042_flush()
269 dbg("%02x <- i8042 (flush, %s)\n", in i8042_flush()
281 * encoded in bits 8-11 of the command number.
289 return -1; in __i8042_command()
295 dbg("%02x -> i8042 (command)\n", command & 0xff); in __i8042_command()
301 dbg(" -- i8042 (wait write timeout)\n"); in __i8042_command()
304 dbg("%02x -> i8042 (parameter)\n", param[i]); in __i8042_command()
311 dbg(" -- i8042 (wait read timeout)\n"); in __i8042_command()
317 dbg(" -- i8042 (auxerr)\n"); in __i8042_command()
318 return -1; in __i8042_command()
322 dbg("%02x <- i8042 (return)\n", param[i]); in __i8042_command()
331 return -1; in i8042_command()
340 * i8042_kbd_write() sends a byte out through the keyboard interface.
353 dbg("%02x -> i8042 (kbd-data)\n", c); in i8042_kbd_write()
365 struct i8042_port *port = serio->port_data; in i8042_aux_write()
367 return i8042_command(&c, port->mux == -1 ? in i8042_aux_write()
369 I8042_CMD_MUX_SEND + port->mux); in i8042_aux_write()
375 * and then re-enabling it.
419 struct i8042_port *port = serio->port_data; in i8042_start()
421 device_set_wakeup_capable(&serio->dev, true); in i8042_start()
424 * On platforms using suspend-to-idle, allow the keyboard to in i8042_start()
425 * wake up the system from sleep by enabling keyboard wakeups in i8042_start()
426 * by default. This is consistent with keyboard wakeup in i8042_start()
427 * behavior on many platforms using suspend-to-RAM (ACPI S3) in i8042_start()
432 device_set_wakeup_enable(&serio->dev, true); in i8042_start()
436 port->exists = true; in i8042_start()
442 * i8042_stop() marks serio port as non-existing so i8042_interrupt
448 struct i8042_port *port = serio->port_data; in i8042_stop()
451 port->exists = false; in i8042_stop()
452 port->serio = NULL; in i8042_stop()
477 i8042_suppress_kbd_ack--; in i8042_filter()
478 dbg("Extra keyboard ACK - filtered out\n"); in i8042_filter()
550 * i8042_handle_data() is the most important function in this driver -
585 serio = port->exists ? port->serio : NULL; in i8042_handle_data()
587 filter_dbg(port->driver_bound, in i8042_handle_data()
588 data, "<- i8042 (interrupt, %d, %d%s%s)\n", in i8042_handle_data()
613 * i8042_enable_kbd_port enables keyboard port on chip
625 return -EIO; in i8042_enable_kbd_port()
644 return -EIO; in i8042_enable_aux_port()
652 * the controller has been switched into Multiplexed mode
669 * i8042_set_mux_mode checks whether the controller has an
685 * Internal loopback test - send three bytes, they should come back from the in i8042_set_mux_mode()
691 return -1; in i8042_set_mux_mode()
694 return -1; in i8042_set_mux_mode()
697 return -1; in i8042_set_mux_mode()
704 return -1; in i8042_set_mux_mode()
713 * i8042_check_mux() checks whether the controller supports the PS/2 Active
723 return -1; in i8042_check_mux()
725 pr_info("Detected active multiplexing controller, rev %d.%d\n", in i8042_check_mux()
736 return -EIO; in i8042_check_mux()
761 dbg("%02x <- i8042 (aux_test_irq, %s)\n", in i8042_aux_test_irq()
771 * i8042_toggle_aux - enables or disables AUX port on i8042 via command and
782 return -1; in i8042_toggle_aux()
789 return -1; in i8042_toggle_aux()
795 return -1; in i8042_toggle_aux()
805 int retval = -1; in i8042_check_aux()
817 * Internal loopback test - filters out AT-type i8042's. Unfortunately in i8042_check_aux()
827 * External connection test - filters out AT-soldered PS/2 i8042's in i8042_check_aux()
828 * 0x00 - no error, 0x01-0x03 - clock/data stuck, 0xff - general error in i8042_check_aux()
829 * 0xfa - no error on some notebooks which ignore the spec in i8042_check_aux()
836 return -1; in i8042_check_aux()
847 * Bit assignment test - filters out PS/2 i8042's in AT mode in i8042_check_aux()
856 return -1; in i8042_check_aux()
859 * Reset keyboard (needed on some laptops to successfully detect in i8042_check_aux()
904 * AUX IRQ was never delivered so we need to flush the controller to in i8042_check_aux()
905 * get rid of the byte we put there; otherwise keyboard may not work. in i8042_check_aux()
907 dbg(" -- i8042 (aux irq test timeout)\n"); in i8042_check_aux()
909 retval = -1; in i8042_check_aux()
922 retval = -1; in i8042_check_aux()
933 pr_info("No controller found\n"); in i8042_controller_check()
934 return -ENODEV; in i8042_controller_check()
952 pr_err("i8042 controller selftest timeout\n"); in i8042_controller_selftest()
953 return -ENODEV; in i8042_controller_selftest()
959 dbg("i8042 controller selftest: %#x != %#x\n", in i8042_controller_selftest()
966 * On x86, we don't fail entire i8042 initialization if controller in i8042_controller_selftest()
967 * reset fails in hopes that keyboard port will still be functional in i8042_controller_selftest()
968 * and user will still get a working keyboard. This is especially in i8042_controller_selftest()
971 pr_info("giving up on controller selftest, continuing anyway...\n"); in i8042_controller_selftest()
974 pr_err("i8042 controller selftest failed\n"); in i8042_controller_selftest()
975 return -EIO; in i8042_controller_selftest()
980 * i8042_controller_init initializes the i8042 controller, and,
981 * most importantly, sets it into non-xlated mode if that's
997 return -EIO; in i8042_controller_init()
1005 return i8042_probe_defer ? -EPROBE_DEFER : -EIO; in i8042_controller_init()
1013 * Disable the keyboard interface and interrupt. in i8042_controller_init()
1056 return -EIO; in i8042_controller_init()
1060 * Flush whatever accumulated while we were disabling keyboard port. in i8042_controller_init()
1070 * Reset the controller and reset CRT to the original value set by BIOS.
1095 * Reset the controller if requested. in i8042_controller_reset()
1113 * i8042_panic_blink() will turn the keyboard LEDs on or off and is called
1132 dbg("%02x -> i8042 (panic blink)\n", 0xed); in i8042_panic_blink()
1139 dbg("%02x -> i8042 (panic blink)\n", led); in i8042_panic_blink()
1195 return -EIO; in i8042_controller_resume()
1236 if (serio && device_may_wakeup(&serio->dev)) in i8042_pm_suspend()
1259 if (serio && device_may_wakeup(&serio->dev)) in i8042_pm_resume()
1265 * not restore the controller state to whatever it had been at boot in i8042_pm_resume()
1272 * We only need to reset the controller if we are resuming after handing in i8042_pm_resume()
1328 return -ENOMEM; in i8042_create_kbd_port()
1330 serio->id.type = i8042_direct ? SERIO_8042 : SERIO_8042_XL; in i8042_create_kbd_port()
1331 serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write; in i8042_create_kbd_port()
1332 serio->start = i8042_start; in i8042_create_kbd_port()
1333 serio->stop = i8042_stop; in i8042_create_kbd_port()
1334 serio->close = i8042_port_close; in i8042_create_kbd_port()
1335 serio->ps2_cmd_mutex = &i8042_mutex; in i8042_create_kbd_port()
1336 serio->port_data = port; in i8042_create_kbd_port()
1337 serio->dev.parent = &i8042_platform_device->dev; in i8042_create_kbd_port()
1338 strscpy(serio->name, "i8042 KBD port", sizeof(serio->name)); in i8042_create_kbd_port()
1339 strscpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); in i8042_create_kbd_port()
1340 strscpy(serio->firmware_id, i8042_kbd_firmware_id, in i8042_create_kbd_port()
1341 sizeof(serio->firmware_id)); in i8042_create_kbd_port()
1342 set_primary_fwnode(&serio->dev, i8042_kbd_fwnode); in i8042_create_kbd_port()
1344 port->serio = serio; in i8042_create_kbd_port()
1345 port->irq = I8042_KBD_IRQ; in i8042_create_kbd_port()
1358 return -ENOMEM; in i8042_create_aux_port()
1360 serio->id.type = SERIO_8042; in i8042_create_aux_port()
1361 serio->write = i8042_aux_write; in i8042_create_aux_port()
1362 serio->start = i8042_start; in i8042_create_aux_port()
1363 serio->stop = i8042_stop; in i8042_create_aux_port()
1364 serio->ps2_cmd_mutex = &i8042_mutex; in i8042_create_aux_port()
1365 serio->port_data = port; in i8042_create_aux_port()
1366 serio->dev.parent = &i8042_platform_device->dev; in i8042_create_aux_port()
1368 strscpy(serio->name, "i8042 AUX port", sizeof(serio->name)); in i8042_create_aux_port()
1369 strscpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); in i8042_create_aux_port()
1370 strscpy(serio->firmware_id, i8042_aux_firmware_id, in i8042_create_aux_port()
1371 sizeof(serio->firmware_id)); in i8042_create_aux_port()
1372 serio->close = i8042_port_close; in i8042_create_aux_port()
1374 snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx); in i8042_create_aux_port()
1375 snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, idx + 1); in i8042_create_aux_port()
1376 strscpy(serio->firmware_id, i8042_aux_firmware_id, in i8042_create_aux_port()
1377 sizeof(serio->firmware_id)); in i8042_create_aux_port()
1380 port->serio = serio; in i8042_create_aux_port()
1381 port->mux = idx; in i8042_create_aux_port()
1382 port->irq = I8042_AUX_IRQ; in i8042_create_aux_port()
1414 serio->name, in i8042_register_ports()
1451 return -ENODEV; in i8042_setup_aux()
1454 error = i8042_create_aux_port(-1); in i8042_setup_aux()
1518 struct i8042_port *port = serio->port_data; in i8042_kbd_bind_notifier()
1525 port->driver_bound = true; in i8042_kbd_bind_notifier()
1529 port->driver_bound = false; in i8042_kbd_bind_notifier()
1557 if (error && error != -ENODEV && error != -EBUSY) in i8042_probe()
1612 return (err == -ENODEV) ? 0 : err; in i8042_init()
1625 i8042_platform_device = platform_device_alloc("i8042", -1); in i8042_init()
1627 err = -ENOMEM; in i8042_init()