Skip to content

Commit 9ee0a05

Browse files
Danilo Krummrichdtor
authored andcommitted
Input: PS/2 gpio bit banging driver for serio bus
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>
1 parent 0ca0681 commit 9ee0a05

5 files changed

Lines changed: 493 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Device-Tree binding for ps/2 gpio device
2+
3+
Required properties:
4+
- compatible = "ps2-gpio"
5+
- data-gpios: the data pin
6+
- clk-gpios: the clock pin
7+
- interrupts: Should trigger on the falling edge of the clock line.
8+
9+
Optional properties:
10+
- write-enable: Indicates whether write function is provided
11+
to serio device. Possibly providing the write fn will not work, because
12+
of the tough timing requirements.
13+
14+
Example nodes:
15+
16+
ps2@0 {
17+
compatible = "ps2-gpio";
18+
interrupt-parent = <&gpio>;
19+
interrupts = <23 IRQ_TYPE_EDGE_FALLING>;
20+
data-gpios = <&gpio 24 GPIO_ACTIVE_HIGH>;
21+
clk-gpios = <&gpio 23 GPIO_ACTIVE_HIGH>;
22+
write-enable;
23+
};

Documentation/gpio/drivers-on-gpio.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ hardware descriptions such as device tree or ACPI:
8484
NAND flash MTD subsystem and provides chip access and partition parsing like
8585
any other NAND driving hardware.
8686

87+
- ps2-gpio: drivers/input/serio/ps2-gpio.c is used to drive a PS/2 (IBM) serio
88+
bus, data and clock line, by bit banging two GPIO lines. It will appear as
89+
any other serio bus to the system and makes it possible to connect drivers
90+
for e.g. keyboards and other PS/2 protocol based devices.
91+
8792
Apart from this there are special GPIO drivers in subsystems like MMC/SD to
8893
read card detect and write protect GPIO lines, and in the TTY serial subsystem
8994
to emulate MCTRL (modem control) signals CTS/RTS by using two GPIO lines. The

drivers/input/serio/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,17 @@ config SERIO_SUN4I_PS2
292292
To compile this driver as a module, choose M here: the
293293
module will be called sun4i-ps2.
294294

295+
config SERIO_GPIO_PS2
296+
tristate "GPIO PS/2 bit banging driver"
297+
depends on GPIOLIB
298+
help
299+
Say Y here if you want PS/2 bit banging support via GPIO.
300+
301+
To compile this driver as a module, choose M here: the
302+
module will be called ps2-gpio.
303+
304+
If you are unsure, say N.
305+
295306
config USERIO
296307
tristate "User space serio port driver support"
297308
help

drivers/input/serio/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ obj-$(CONFIG_SERIO_APBPS2) += apbps2.o
3030
obj-$(CONFIG_SERIO_OLPC_APSP) += olpc_apsp.o
3131
obj-$(CONFIG_HYPERV_KEYBOARD) += hyperv-keyboard.o
3232
obj-$(CONFIG_SERIO_SUN4I_PS2) += sun4i-ps2.o
33+
obj-$(CONFIG_SERIO_GPIO_PS2) += ps2-gpio.o
3334
obj-$(CONFIG_USERIO) += userio.o

0 commit comments

Comments
 (0)