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
59 static int i8042_set_reset(const char *val, const struct kernel_param *kp) in i8042_set_reset()
61 enum i8042_controller_reset_mode *arg = kp->arg; in i8042_set_reset()
62 int error; in i8042_set_reset()
88 MODULE_PARM_DESC(direct, "Put keyboard port into non-translated mode.");
130 …enable (may reveal sensitive data) of normally sanitize-filtered kbd data traffic debug log [pre-c…
159 int irq;
181 static irqreturn_t i8042_interrupt(int irq, void *dev_id);
197 int i8042_install_filter(bool (*filter)(unsigned char data, unsigned char str, in i8042_install_filter()
201 int ret = 0; in i8042_install_filter()
206 ret = -EBUSY; in i8042_install_filter()
218 int i8042_remove_filter(bool (*filter)(unsigned char data, unsigned char str, in i8042_remove_filter()
222 int ret = 0; in i8042_remove_filter()
227 ret = -EINVAL; in i8042_remove_filter()
245 static int i8042_wait_read(void) in i8042_wait_read()
247 int i = 0; in i8042_wait_read()
253 return -(i == I8042_CTL_TIMEOUT); in i8042_wait_read()
256 static int i8042_wait_write(void) in i8042_wait_write()
258 int i = 0; in i8042_wait_write()
264 return -(i == I8042_CTL_TIMEOUT); in i8042_wait_write()
272 static int i8042_flush(void) in i8042_flush()
276 int count = 0; in i8042_flush()
277 int retval = 0; in i8042_flush()
285 dbg("%02x <- i8042 (flush, %s)\n", in i8042_flush()
288 retval = -EIO; in i8042_flush()
303 * encoded in bits 8-11 of the command number.
306 static int __i8042_command(unsigned char *param, int command) in __i8042_command()
308 int i, error; in __i8042_command()
311 return -1; in __i8042_command()
317 dbg("%02x -> i8042 (command)\n", command & 0xff); in __i8042_command()
323 dbg(" -- i8042 (wait write timeout)\n"); in __i8042_command()
326 dbg("%02x -> i8042 (parameter)\n", param[i]); in __i8042_command()
333 dbg(" -- i8042 (wait read timeout)\n"); in __i8042_command()
339 dbg(" -- i8042 (auxerr)\n"); in __i8042_command()
340 return -1; in __i8042_command()
344 dbg("%02x <- i8042 (return)\n", param[i]); in __i8042_command()
350 int i8042_command(unsigned char *param, int command) in i8042_command()
353 int retval; in i8042_command()
356 return -1; in i8042_command()
370 static int i8042_kbd_write(struct serio *port, unsigned char c) in i8042_kbd_write()
373 int retval = 0; in i8042_kbd_write()
378 dbg("%02x -> i8042 (kbd-data)\n", c); in i8042_kbd_write()
391 static int i8042_aux_write(struct serio *serio, unsigned char c) in i8042_aux_write()
393 struct i8042_port *port = serio->port_data; in i8042_aux_write()
395 return i8042_command(&c, port->mux == -1 ? in i8042_aux_write()
397 I8042_CMD_MUX_SEND + port->mux); in i8042_aux_write()
403 * and then re-enabling it.
408 int irq_bit; in i8042_port_close()
409 int disable_bit; in i8042_port_close()
445 static int i8042_start(struct serio *serio) in i8042_start()
447 struct i8042_port *port = serio->port_data; in i8042_start()
449 device_set_wakeup_capable(&serio->dev, true); in i8042_start()
452 * On platforms using suspend-to-idle, allow the keyboard to in i8042_start()
455 * behavior on many platforms using suspend-to-RAM (ACPI S3) in i8042_start()
460 device_set_wakeup_enable(&serio->dev, true); in i8042_start()
464 port->exists = true; in i8042_start()
471 * i8042_stop() marks serio port as non-existing so i8042_interrupt
477 struct i8042_port *port = serio->port_data; in i8042_stop()
480 port->exists = false; in i8042_stop()
481 port->serio = NULL; in i8042_stop()
506 i8042_suppress_kbd_ack--; in i8042_filter()
507 dbg("Extra keyboard ACK - filtered out\n"); in i8042_filter()
521 * i8042_interrupt() is the most important function in this driver -
526 static irqreturn_t i8042_interrupt(int irq, void *dev_id) in i8042_interrupt()
532 unsigned int dfl; in i8042_interrupt()
533 unsigned int port_no; in i8042_interrupt()
535 int ret = 1; in i8042_interrupt()
598 serio = port->exists ? port->serio : NULL; in i8042_interrupt()
600 filter_dbg(port->driver_bound, data, "<- i8042 (interrupt, %d, %d%s%s)\n", in i8042_interrupt()
620 static int i8042_enable_kbd_port(void) in i8042_enable_kbd_port()
629 return -EIO; in i8042_enable_kbd_port()
639 static int i8042_enable_aux_port(void) in i8042_enable_aux_port()
648 return -EIO; in i8042_enable_aux_port()
659 static int i8042_enable_mux_ports(void) in i8042_enable_mux_ports()
662 int i; in i8042_enable_mux_ports()
678 static int i8042_set_mux_mode(bool multiplex, unsigned char *mux_version) in i8042_set_mux_mode()
689 * Internal loopback test - send three bytes, they should come back from the in i8042_set_mux_mode()
695 return -1; in i8042_set_mux_mode()
698 return -1; in i8042_set_mux_mode()
701 return -1; in i8042_set_mux_mode()
708 return -1; in i8042_set_mux_mode()
722 static int i8042_check_mux(void) in i8042_check_mux()
727 return -1; in i8042_check_mux()
740 return -EIO; in i8042_check_mux()
754 static irqreturn_t i8042_aux_test_irq(int irq, void *dev_id) in i8042_aux_test_irq()
758 int ret = 0; in i8042_aux_test_irq()
764 dbg("%02x <- i8042 (aux_test_irq, %s)\n", in i8042_aux_test_irq()
777 * i8042_toggle_aux - enables or disables AUX port on i8042 via command and
781 static int i8042_toggle_aux(bool on) in i8042_toggle_aux()
784 int i; in i8042_toggle_aux()
788 return -1; in i8042_toggle_aux()
795 return -1; in i8042_toggle_aux()
801 return -1; in i8042_toggle_aux()
809 static int i8042_check_aux(void) in i8042_check_aux()
811 int retval = -1; in i8042_check_aux()
824 * Internal loopback test - filters out AT-type i8042's. Unfortunately in i8042_check_aux()
834 * External connection test - filters out AT-soldered PS/2 i8042's in i8042_check_aux()
835 * 0x00 - no error, 0x01-0x03 - clock/data stuck, 0xff - general error in i8042_check_aux()
836 * 0xfa - no error on some notebooks which ignore the spec in i8042_check_aux()
843 return -1; in i8042_check_aux()
847 * mark it as broken in i8042_check_aux()
854 * Bit assignment test - filters out PS/2 i8042's in AT mode in i8042_check_aux()
863 return -1; in i8042_check_aux()
917 dbg(" -- i8042 (aux irq test timeout)\n"); in i8042_check_aux()
919 retval = -1; in i8042_check_aux()
932 retval = -1; in i8042_check_aux()
940 static int i8042_controller_check(void) in i8042_controller_check()
944 return -ENODEV; in i8042_controller_check()
950 static int i8042_controller_selftest(void) in i8042_controller_selftest()
953 int i = 0; in i8042_controller_selftest()
963 return -ENODEV; in i8042_controller_selftest()
985 return -EIO; in i8042_controller_selftest()
991 * most importantly, sets it into non-xlated mode if that's
995 static int i8042_controller_init(void) in i8042_controller_init()
998 int n = 0; in i8042_controller_init()
1007 pr_err("Unable to get stable CTR read\n"); in i8042_controller_init()
1008 return -EIO; in i8042_controller_init()
1016 return i8042_probe_defer ? -EPROBE_DEFER : -EIO; in i8042_controller_init()
1067 return -EIO; in i8042_controller_init()
1135 static long i8042_panic_blink(int state) in i8042_panic_blink()
1143 dbg("%02x -> i8042 (panic blink)\n", 0xed); in i8042_panic_blink()
1150 dbg("%02x -> i8042 (panic blink)\n", led); in i8042_panic_blink()
1162 int error; in i8042_dritek_enable()
1177 static int i8042_controller_resume(bool s2r_wants_reset) in i8042_controller_resume()
1179 int error; in i8042_controller_resume()
1206 return -EIO; in i8042_controller_resume()
1235 static int i8042_pm_suspend(struct device *dev) in i8042_pm_suspend()
1237 int i; in i8042_pm_suspend()
1246 if (serio && device_may_wakeup(&serio->dev)) in i8042_pm_suspend()
1253 static int i8042_pm_resume_noirq(struct device *dev) in i8042_pm_resume_noirq()
1261 static int i8042_pm_resume(struct device *dev) in i8042_pm_resume()
1264 int i; in i8042_pm_resume()
1269 if (serio && device_may_wakeup(&serio->dev)) in i8042_pm_resume()
1291 static int i8042_pm_thaw(struct device *dev) in i8042_pm_thaw()
1298 static int i8042_pm_reset(struct device *dev) in i8042_pm_reset()
1305 static int i8042_pm_restore(struct device *dev) in i8042_pm_restore()
1331 static int i8042_create_kbd_port(void) in i8042_create_kbd_port()
1338 return -ENOMEM; in i8042_create_kbd_port()
1340 serio->id.type = i8042_direct ? SERIO_8042 : SERIO_8042_XL; in i8042_create_kbd_port()
1341 serio->write = i8042_dumbkbd ? NULL : i8042_kbd_write; in i8042_create_kbd_port()
1342 serio->start = i8042_start; in i8042_create_kbd_port()
1343 serio->stop = i8042_stop; in i8042_create_kbd_port()
1344 serio->close = i8042_port_close; in i8042_create_kbd_port()
1345 serio->ps2_cmd_mutex = &i8042_mutex; in i8042_create_kbd_port()
1346 serio->port_data = port; in i8042_create_kbd_port()
1347 serio->dev.parent = &i8042_platform_device->dev; in i8042_create_kbd_port()
1348 strscpy(serio->name, "i8042 KBD port", sizeof(serio->name)); in i8042_create_kbd_port()
1349 strscpy(serio->phys, I8042_KBD_PHYS_DESC, sizeof(serio->phys)); in i8042_create_kbd_port()
1350 strscpy(serio->firmware_id, i8042_kbd_firmware_id, in i8042_create_kbd_port()
1351 sizeof(serio->firmware_id)); in i8042_create_kbd_port()
1352 set_primary_fwnode(&serio->dev, i8042_kbd_fwnode); in i8042_create_kbd_port()
1354 port->serio = serio; in i8042_create_kbd_port()
1355 port->irq = I8042_KBD_IRQ; in i8042_create_kbd_port()
1360 static int i8042_create_aux_port(int idx) in i8042_create_aux_port()
1363 int port_no = idx < 0 ? I8042_AUX_PORT_NO : I8042_MUX_PORT_NO + idx; in i8042_create_aux_port()
1368 return -ENOMEM; in i8042_create_aux_port()
1370 serio->id.type = SERIO_8042; in i8042_create_aux_port()
1371 serio->write = i8042_aux_write; in i8042_create_aux_port()
1372 serio->start = i8042_start; in i8042_create_aux_port()
1373 serio->stop = i8042_stop; in i8042_create_aux_port()
1374 serio->ps2_cmd_mutex = &i8042_mutex; in i8042_create_aux_port()
1375 serio->port_data = port; in i8042_create_aux_port()
1376 serio->dev.parent = &i8042_platform_device->dev; in i8042_create_aux_port()
1378 strscpy(serio->name, "i8042 AUX port", sizeof(serio->name)); in i8042_create_aux_port()
1379 strscpy(serio->phys, I8042_AUX_PHYS_DESC, sizeof(serio->phys)); in i8042_create_aux_port()
1380 strscpy(serio->firmware_id, i8042_aux_firmware_id, in i8042_create_aux_port()
1381 sizeof(serio->firmware_id)); in i8042_create_aux_port()
1382 serio->close = i8042_port_close; in i8042_create_aux_port()
1384 snprintf(serio->name, sizeof(serio->name), "i8042 AUX%d port", idx); in i8042_create_aux_port()
1385 snprintf(serio->phys, sizeof(serio->phys), I8042_MUX_PHYS_DESC, idx + 1); in i8042_create_aux_port()
1386 strscpy(serio->firmware_id, i8042_aux_firmware_id, in i8042_create_aux_port()
1387 sizeof(serio->firmware_id)); in i8042_create_aux_port()
1390 port->serio = serio; in i8042_create_aux_port()
1391 port->mux = idx; in i8042_create_aux_port()
1392 port->irq = I8042_AUX_IRQ; in i8042_create_aux_port()
1405 int i; in i8042_free_aux_ports()
1415 int i; in i8042_register_ports()
1424 serio->name, in i8042_register_ports()
1434 int i; in i8042_unregister_ports()
1454 static int i8042_setup_aux(void) in i8042_setup_aux()
1456 int (*aux_enable)(void); in i8042_setup_aux()
1457 int error; in i8042_setup_aux()
1458 int i; in i8042_setup_aux()
1461 return -ENODEV; in i8042_setup_aux()
1464 error = i8042_create_aux_port(-1); in i8042_setup_aux()
1496 static int i8042_setup_kbd(void) in i8042_setup_kbd()
1498 int error; in i8042_setup_kbd()
1523 static int i8042_kbd_bind_notifier(struct notifier_block *nb, in i8042_kbd_bind_notifier()
1528 struct i8042_port *port = serio->port_data; in i8042_kbd_bind_notifier()
1535 port->driver_bound = true; in i8042_kbd_bind_notifier()
1539 port->driver_bound = false; in i8042_kbd_bind_notifier()
1546 static int i8042_probe(struct platform_device *dev) in i8042_probe()
1548 int error; in i8042_probe()
1567 if (error && error != -ENODEV && error != -EBUSY) in i8042_probe()
1614 static int __init i8042_init(void) in i8042_init()
1616 int err; in i8042_init()
1622 return (err == -ENODEV) ? 0 : err; in i8042_init()
1635 i8042_platform_device = platform_device_alloc("i8042", -1); in i8042_init()
1637 err = -ENOMEM; in i8042_init()