aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/serio/ps2-gpio.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-08-18Input: move from strlcpy with unused retval to strscpyWolfram Sang1-2/+2
Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/20220818210022.6865-1-wsa+renesas@sang-engineering.com Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2022-02-15Input: ps2-gpio - enforce GPIOs flag open drainDanilo Krummrich1-2/+7
The PS/2 bus defines the data and clock line be open drain, therefore for both enforce the particular GPIO flags in the driver. Without enforcing to flag at least the clock gpio as open drain we run into the following warning: WARNING: CPU: 1 PID: 40 at drivers/gpio/gpiolib.c:3175 gpiochip_enable_irq+0x54/0x90 gpiochip_enable_irq() warns on a GPIO being configured as output while serving as IRQ source without being flagged as open drain. Signed-off-by: Danilo Krummrich <danilokrummrich@dk-develop.de> Link: https://lore.kernel.org/r/20220215180829.63543-4-danilokrummrich@dk-develop.de Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2022-02-15Input: ps2-gpio - don't send rx data before the stop bitDanilo Krummrich1-14/+8
Sending the data before processing the stop bit from the device already saves the data of the current xfer in case the stop bit is missed. However, when TX xfers are enabled this introduces a race condition when a peripheral driver using the bus immediately requests a TX xfer from IRQ context. Therefore the data must be send after receiving the stop bit, although it is possible the data is lost when missing the stop bit. Signed-off-by: Danilo Krummrich <danilokrummrich@dk-develop.de> Link: https://lore.kernel.org/r/20220215160208.34826-5-danilokrummrich@dk-develop.de Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2022-02-15Input: ps2-gpio - remove tx timeout from ps2_gpio_irq_tx()Danilo Krummrich1-9/+1
Actually, there's no extra clock pulse to wait for. The assumption of an extra clock pulse was mistakenly derived from the fact that by the time this driver was introduced the GPIO controller of the test machine (bcm2835) generated spurious interrupts. Since now spurious interrupts are handled properly this can and must be removed in order to make TX xfers work properly. While at it, remove duplicate gpiod_direction_input(). The data gpio must already be configured to act as input when receiving the ACK bit. This patch is tested with the original hardware (peripherals and board) the driver was developed on. Signed-off-by: Danilo Krummrich <danilokrummrich@dk-develop.de> Link: https://lore.kernel.org/r/20220215160208.34826-4-danilokrummrich@dk-develop.de Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2022-02-15Input: ps2-gpio - use ktime for IRQ timekeepingDanilo Krummrich1-20/+82
Using jiffies for the IRQ timekeeping is not sufficient for two reasons: (1) Usually jiffies have a resolution of 1ms to 10ms. The IRQ intervals based on the clock frequency of PS2 protocol specification (10kHz - 16.7kHz) are between ~60us and 100us only. Therefore only those IRQ intervals can be detected which are either at the end of a transfer or are overly delayed. While this is sufficient in most cases, since we have quite a lot of ways to detect faulty transfers, it can produce false positives in rare cases: When the jiffies value changes right between two interrupt that are in time, we wrongly assume that we missed one or more clock cycles. (2) Some gpio controllers (e.g. the one in the bcm283x chips) may generate spurious IRQs when processing interrupts in the frequency given by PS2 devices. Both issues can be fixed by using ktime resolution for IRQ timekeeping. However, it is still possible to miss clock cycles without detecting them. When the PS2 device generates the falling edge of the clock signal we have between ~30us and 50us to sample the data line, because after this time we reach the next rising edge at which the device changes the data signal already. But, the only thing we can detect is whether the IRQ interval is within the given period. Therefore it is possible to have an IRQ latency greater than ~30us to 50us, sample the wrong bit on the data line and still be on time with the next IRQ. However, this can only happen when within a given transfer the IRQ latency increases slowly. ___ ______ ______ ______ ___ \ / \ / \ / \ / \ / \ / \ / \ / \______/ \______/ \______/ \______/ |-----------------| |--------| 60us/100us 30us/50us Signed-off-by: Danilo Krummrich <danilokrummrich@dk-develop.de> Link: https://lore.kernel.org/r/20220215160208.34826-3-danilokrummrich@dk-develop.de Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2022-02-15Input: ps2-gpio - refactor struct ps2_gpio_dataDanilo Krummrich1-28/+32
Refactor struct ps2_gpio_data in order to clearly separate RX and TX state data. This change intends to increase code readability and does not bring any functional change. Signed-off-by: Danilo Krummrich <danilokrummrich@dk-develop.de> Link: https://lore.kernel.org/r/20220215160208.34826-2-danilokrummrich@dk-develop.de Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-08-14Input: remove dev_err() usage after platform_get_irq()Stephen Boyd1-2/+0
We don't need dev_err() messages when platform_get_irq() fails now that platform_get_irq() prints an error message itself when something goes wrong. Let's remove these prints with a simple semantic patch. // <smpl> @@ expression ret; struct platform_device *E; @@ ret = ( platform_get_irq(E, ...) | platform_get_irq_byname(E, ...) ); if ( \( ret < 0 \| ret <= 0 \) ) { ( -if (ret != -EPROBE_DEFER) -{ ... -dev_err(...); -... } | ... -dev_err(...); ) ... } // </smpl> While we're here, remove braces on if statements that only have one statement (manually). Signed-off-by: Stephen Boyd <swboyd@chromium.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2019-06-19treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500Thomas Gleixner1-4/+1
Based on 2 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 as published by the free software foundation # extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 4122 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Enrico Weigelt <info@metux.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190604081206.933168790@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-02-09Input: ps2-gpio - flush TX work when closing portDmitry Torokhov1-0/+1
To ensure that TX work is not running after serio port has been torn down, let's flush it when closing the port. Reported-by: Sven Van Asbroeck <thesven73@gmail.com> Acked-by: Danilo Krummrich <danilokrummrich@dk-develop.de> Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-10-24Input: ps2-gpio - actually abort probe when connected to sleeping GPIOsDmitry Torokhov1-0/+1
We've been missing a goto to the unwind path... Acked-by: Danilo Krummrich <danilokrummrich@dk-develop.de> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2017-08-28Input: PS/2 gpio bit banging driver for serio busDanilo Krummrich1-0/+453
This driver provides PS/2 serio bus support by implementing bit banging with the GPIO API. The GPIO pins, data and clock, can be configured with a node in the device tree or by generic device properties (GDP). Writing to a device is supported as well, though it is possible timings can not be halt as they are tough and difficult to reach with bit banging. Therefore it can be configured (also in DT and GDP) whether the serio write function should be available for clients. This driver is for development purposes and not recommended for productive use. However, this driver can be useful e.g. when no USB port is available or using old peripherals is desired as PS/2 controller chips getting rare. This driver was tested on bcm2825 and on Kirin 960 and it worked well together with the atkbd and psmouse driver. Signed-off-by: Danilo Krummrich <danilokrummrich@dk-develop.de> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>