Lines Matching +full:int +full:- +full:clock +full:- +full:stable +full:- +full:broken

1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 1999-2004 Vojtech Pavlik
55 static int i8042_set_reset(const char *val, const struct kernel_param *kp) in i8042_set_reset()
57 enum i8042_controller_reset_mode *arg = kp->arg; in i8042_set_reset()
58 int error; in i8042_set_reset()
84 MODULE_PARM_DESC(direct, "Put keyboard port into non-translated mode.");
122 …enable (may reveal sensitive data) of normally sanitize-filtered kbd data traffic debug log [pre-c…
151 int irq;
173 static irqreturn_t i8042_interrupt(int irq, void *dev_id);
189 int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str, in i8042_install_filter()
193 int ret = 0; in i8042_install_filter()
198 ret = -EBUSY; in i8042_install_filter()
210 int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str, in i8042_remove_filter()
214 int ret = 0; in i8042_remove_filter()
219 ret = -EINVAL; in i8042_remove_filter()
237 static int i8042_wait_read(void) in i8042_wait_read()
239 int i = 0; in i8042_wait_read()
245 return -(i == I8042_CTL_TIMEOUT); in i8042_wait_read()
248 static int i8042_wait_write(void) in i8042_wait_write()
250 int i = 0; in i8042_wait_write()
256 return -(i == I8042_CTL_TIMEOUT); in i8042_wait_write()
264 static int i8042_flush(void) in i8042_flush()
268 int count = 0; in i8042_flush()
269 int retval = 0; in i8042_flush()
277 dbg("%02x <- i8042 (flush, %s)\n", in i8042_flush()
280 retval = -EIO; in i8042_flush()
295 * encoded in bits 8-11 of the command number.
298 static int __i8042_command(unsigned char *param, int command) in __i8042_command()
300 int i, error; in __i8042_command()
303 return -1; in __i8042_command()
309 dbg("%02x -> i8042 (command)\n", command & 0xff); in __i8042_command()
315 dbg(" -- i8042 (wait write timeout)\n"); in __i8042_command()
318 dbg("%02x -> i8042 (parameter)\n", param[i]); in __i8042_command()
325 dbg(" -- i8042 (wait read timeout)\n"); in __i8042_command()
331 dbg(" -- i8042 (auxerr)\n"); in __i8042_command()
332 return -1; in __i8042_command()
336 dbg("%02x <- i8042 (return)\n", param[i]); in __i8042_command()
342 int i8042_command(unsigned char *param, int command) in i8042_command()
345 int retval; in i8042_command()
348 return -1; in i8042_command()
362 static int i8042_kbd_write(struct serio *port, unsigned char c) in i8042_kbd_write()
365 int retval = 0; in i8042_kbd_write()
370 dbg("%02x -> i8042 (kbd-data)\n", c); in i8042_kbd_write()
383 static int i8042_aux_write(struct serio *serio, unsigned char c) in i8042_aux_write()
385 struct i8042_port *port = serio->port_data; in i8042_aux_write()
387 return i8042_command(&c, port->mux == -1 ? in i8042_aux_write()
389 I8042_CMD_MUX_SEND + port->mux); in i8042_aux_write()
395 * and then re-enabling it.
400 int irq_bit; in i8042_port_close()
401 int disable_bit; in i8042_port_close()
437 static int i8042_start(struct serio *serio) in i8042_start()
439 struct i8042_port *port = serio->port_data; in i8042_start()
441 device_set_wakeup_capable(&serio->dev, true); in i8042_start()
444 * On platforms using suspend-to-idle, allow the keyboard to in i8042_start()
447 * behavior on many platforms using suspend-to-RAM (ACPI S3) in i8042_start()
452 device_set_wakeup_enable(&serio->dev, true); in i8042_start()
456 port->exists = true; in i8042_start()
463 * i8042_stop() marks serio port as non-existing so i8042_interrupt
469 struct i8042_port *port = serio->port_data; in i8042_stop()
472 port->exists = false; in i8042_stop()
473 port->serio = NULL; in i8042_stop()
498 i8042_suppress_kbd_ack--; in i8042_filter()
499 dbg("Extra keyboard ACK - filtered out\n"); in i8042_filter()
513 * i8042_interrupt() is the most important function in this driver -
518 static irqreturn_t i8042_interrupt(int irq, void *dev_id) in i8042_interrupt()
524 unsigned int dfl; in i8042_interrupt()
525 unsigned int port_no; in i8042_interrupt()
527 int ret = 1; in i8042_interrupt()
590 serio = port->exists ? port->serio : NULL; in i8042_interrupt()
592 filter_dbg(port->driver_bound, data, "<- i8042 (interrupt, %d, %d%s%s)\n", in i8042_interrupt()
612 static int i8042_enable_kbd_port(void) in i8042_enable_kbd_port()
621 return -EIO; in i8042_enable_kbd_port()
631 static int i8042_enable_aux_port(void) in i8042_enable_aux_port()
640 return -EIO; in i8042_enable_aux_port()
651 static int i8042_enable_mux_ports(void) in i8042_enable_mux_ports()
654 int i; in i8042_enable_mux_ports()
670 static int i8042_set_mux_mode(bool multiplex, unsigned char *mux_version) in i8042_set_mux_mode()
681 * Internal loopback test - send three bytes, they should come back from the in i8042_set_mux_mode()
687 return -1; in i8042_set_mux_mode()
690 return -1; in i8042_set_mux_mode()
693 return -1; in i8042_set_mux_mode()
700 return -1; in i8042_set_mux_mode()
714 static int __init i8042_check_mux(void) in i8042_check_mux()
719 return -1; in i8042_check_mux()
732 return -EIO; in i8042_check_mux()
746 static irqreturn_t __init i8042_aux_test_irq(int irq, void *dev_id) in i8042_aux_test_irq()
750 int ret = 0; in i8042_aux_test_irq()
756 dbg("%02x <- i8042 (aux_test_irq, %s)\n", in i8042_aux_test_irq()
769 * i8042_toggle_aux - enables or disables AUX port on i8042 via command and
773 static int __init i8042_toggle_aux(bool on) in i8042_toggle_aux()
776 int i; in i8042_toggle_aux()
780 return -1; in i8042_toggle_aux()
787 return -1; in i8042_toggle_aux()
793 return -1; in i8042_toggle_aux()
801 static int __init i8042_check_aux(void) in i8042_check_aux()
803 int retval = -1; in i8042_check_aux()
816 * Internal loopback test - filters out AT-type i8042's. Unfortunately in i8042_check_aux()
826 * External connection test - filters out AT-soldered PS/2 i8042's in i8042_check_aux()
827 * 0x00 - no error, 0x01-0x03 - clock/data stuck, 0xff - general error in i8042_check_aux()
828 * 0xfa - no error on some notebooks which ignore the spec in i8042_check_aux()
835 return -1; in i8042_check_aux()
839 * mark it as broken in i8042_check_aux()
846 * Bit assignment test - filters out PS/2 i8042's in AT mode in i8042_check_aux()
855 return -1; in i8042_check_aux()
909 dbg(" -- i8042 (aux irq test timeout)\n"); in i8042_check_aux()
911 retval = -1; in i8042_check_aux()
924 retval = -1; in i8042_check_aux()
932 static int i8042_controller_check(void) in i8042_controller_check()
936 return -ENODEV; in i8042_controller_check()
942 static int i8042_controller_selftest(void) in i8042_controller_selftest()
945 int i = 0; in i8042_controller_selftest()
955 return -ENODEV; in i8042_controller_selftest()
977 return -EIO; in i8042_controller_selftest()
983 * most importantly, sets it into non-xlated mode if that's
987 static int i8042_controller_init(void) in i8042_controller_init()
990 int n = 0; in i8042_controller_init()
999 pr_err("Unable to get stable CTR read\n"); in i8042_controller_init()
1000 return -EIO; in i8042_controller_init()
1008 return -EIO; in i8042_controller_init()
1059 return -EIO; in i8042_controller_init()
1127 static long i8042_panic_blink(int state) in i8042_panic_blink()
1135 dbg("%02x -> i8042 (panic blink)\n", 0xed); in i8042_panic_blink()
1142 dbg("%02x -> i8042 (panic blink)\n", led); in i8042_panic_blink()
1154 int error; in i8042_dritek_enable()
1169 static int i8042_controller_resume(bool s2r_wants_reset) in i8042_controller_resume()
1171 int error; in i8042_controller_resume()
1198 return -EIO; in i8042_controller_resume()
1227 static int i8042_pm_suspend(struct device *dev) in i8042_pm_suspend()
1229 int i; in i8042_pm_suspend()
1238 if (serio && device_may_wakeup(&serio->dev)) in i8042_pm_suspend()
1245 static int i8042_pm_resume_noirq(struct device *dev) in i8042_pm_resume_noirq()
1253 static int i8042_pm_resume(struct device *dev) in i8042_pm_resume()
1256 int i; in i8042_pm_resume()
1261 if (serio && device_may_wakeup(&serio->dev)) in i8042_pm_resume()
1283 static int i8042_pm_thaw(struct device *dev) in i8042_pm_thaw()
1290 static int i8042_pm_reset(struct device *dev) in i8042_pm_reset()
1297 static int i8042_pm_restore(struct device *dev) in i8042_pm_restore()
1323 static int __init i8042_create_kbd_port(void) in i8042_create_kbd_port()
1330 return -ENOMEM; in i8042_create_kbd_port()
1332 serio->id.type = i8042_direct ? SERIO_8042 : SERIO_8042_XL; in i8042_create_kbd_port()
1333 serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write; in i8042_create_kbd_port()
1334 serio->start = i8042_start; in i8042_create_kbd_port()
1335 serio->stop = i8042_stop; in i8042_create_kbd_port()
1336 serio->close = i8042_port_close; in i8042_create_kbd_port()
1337 serio->ps2_cmd_mutex = &i8042_mutex; in i8042_create_kbd_port()
1338 serio->port_data = port; in i8042_create_kbd_port()
1339 serio->dev.parent = &i8042_platform_device->dev; in i8042_create_kbd_port()
1340 strlcpy(serio->name, "i8042 KBD port", sizeof(serio->name)); in i8042_create_kbd_port()
1341 strlcpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); in i8042_create_kbd_port()
1342 strlcpy(serio->firmware_id, i8042_kbd_firmware_id, in i8042_create_kbd_port()
1343 sizeof(serio->firmware_id)); in i8042_create_kbd_port()
1344 set_primary_fwnode(&serio->dev, i8042_kbd_fwnode); in i8042_create_kbd_port()
1346 port->serio = serio; in i8042_create_kbd_port()
1347 port->irq = I8042_KBD_IRQ; in i8042_create_kbd_port()
1352 static int __init i8042_create_aux_port(int idx) in i8042_create_aux_port()
1355 int port_no = idx < 0 ? I8042_AUX_PORT_NO : I8042_MUX_PORT_NO + idx; in i8042_create_aux_port()
1360 return -ENOMEM; in i8042_create_aux_port()
1362 serio->id.type = SERIO_8042; in i8042_create_aux_port()
1363 serio->write = i8042_aux_write; in i8042_create_aux_port()
1364 serio->start = i8042_start; in i8042_create_aux_port()
1365 serio->stop = i8042_stop; in i8042_create_aux_port()
1366 serio->ps2_cmd_mutex = &i8042_mutex; in i8042_create_aux_port()
1367 serio->port_data = port; in i8042_create_aux_port()
1368 serio->dev.parent = &i8042_platform_device->dev; in i8042_create_aux_port()
1370 strlcpy(serio->name, "i8042 AUX port", sizeof(serio->name)); in i8042_create_aux_port()
1371 strlcpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); in i8042_create_aux_port()
1372 strlcpy(serio->firmware_id, i8042_aux_firmware_id, in i8042_create_aux_port()
1373 sizeof(serio->firmware_id)); in i8042_create_aux_port()
1374 serio->close = i8042_port_close; in i8042_create_aux_port()
1376 snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx); in i8042_create_aux_port()
1377 snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, idx + 1); in i8042_create_aux_port()
1378 strlcpy(serio->firmware_id, i8042_aux_firmware_id, in i8042_create_aux_port()
1379 sizeof(serio->firmware_id)); in i8042_create_aux_port()
1382 port->serio = serio; in i8042_create_aux_port()
1383 port->mux = idx; in i8042_create_aux_port()
1384 port->irq = I8042_AUX_IRQ; in i8042_create_aux_port()
1397 int i; in i8042_free_aux_ports()
1407 int i; in i8042_register_ports()
1416 serio->name, in i8042_register_ports()
1426 int i; in i8042_unregister_ports()
1446 static int __init i8042_setup_aux(void) in i8042_setup_aux()
1448 int (*aux_enable)(void); in i8042_setup_aux()
1449 int error; in i8042_setup_aux()
1450 int i; in i8042_setup_aux()
1453 return -ENODEV; in i8042_setup_aux()
1456 error = i8042_create_aux_port(-1); in i8042_setup_aux()
1488 static int __init i8042_setup_kbd(void) in i8042_setup_kbd()
1490 int error; in i8042_setup_kbd()
1515 static int i8042_kbd_bind_notifier(struct notifier_block *nb, in i8042_kbd_bind_notifier()
1520 struct i8042_port *port = serio->port_data; in i8042_kbd_bind_notifier()
1527 port->driver_bound = true; in i8042_kbd_bind_notifier()
1531 port->driver_bound = false; in i8042_kbd_bind_notifier()
1538 static int __init i8042_probe(struct platform_device *dev) in i8042_probe()
1540 int error; in i8042_probe()
1561 if (error && error != -ENODEV && error != -EBUSY) in i8042_probe()
1586 static int i8042_remove(struct platform_device *dev) in i8042_remove()
1611 static int __init i8042_init(void) in i8042_init()
1614 int err; in i8042_init()
1620 return (err == -ENODEV) ? 0 : err; in i8042_init()