From d1d849cae12db71aa81ceedaedc1b17a34790367 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Sat, 19 Jun 2021 18:36:05 -0500 Subject: [PATCH] Input: kb151 - Add a driver for the KB151 keyboard This keyboard is found in the official Pine64 PinePhone keyboard case. It is connected over I2C and runs a libre firmware. Signed-off-by: Samuel Holland --- .../dts/allwinner/sun50i-a64-pinephone.dtsi | 64 +++++ drivers/input/keyboard/Kconfig | 10 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/kb151.c | 246 ++++++++++++++++++ 4 files changed, 321 insertions(+) create mode 100644 drivers/input/keyboard/kb151.c diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi index 4ede9fe66020c..0bdc6eceec609 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi @@ -551,6 +551,70 @@ /* Connected to pogo pins (external spring based pinheader for user addons) */ &i2c2 { status = "okay"; + + keyboard@15 { + compatible = "pine64,kb151"; + reg = <0x15>; + interrupt-parent = <&r_pio>; + interrupts = <0 12 IRQ_TYPE_EDGE_FALLING>; /* PL12 */ + keypad,num-rows = <6>; + keypad,num-columns = <12>; + linux,keymap = ; + wakeup-source; + }; }; &i2s2 { diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index 40a070a2e7f5b..0259e9133f469 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig @@ -353,6 +353,16 @@ config KEYBOARD_HP7XX To compile this driver as a module, choose M here: the module will be called jornada720_kbd. +config KEYBOARD_KB151 + tristate "Pine64 KB151 Keyboard" + depends on I2C + select CRC8 + select INPUT_MATRIXKMAP + help + Say Y here to enable support for the KB151 keyboard used in the + Pine64 PinePhone keyboard case. This driver supports the FLOSS + firmware available at https://megous.com/git/pinephone-keyboard/ + config KEYBOARD_LM8323 tristate "LM8323 keypad chip" depends on I2C From 2423aac2d6f5db55da99e11fd799ee66fe6f54c6 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 9 Aug 2021 19:30:18 -0500 Subject: [PATCH] Input: kb151 - Add support for the FN layer Signed-off-by: Samuel Holland --- .../dts/allwinner/sun50i-a64-pinephone.dtsi | 34 +++++++++++++++++-- drivers/input/keyboard/kb151.c | 33 ++++++++++-------- 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi index 0bdc6eceec609..68f5730cf164c 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi @@ -557,7 +557,7 @@ reg = <0x15>; interrupt-parent = <&r_pio>; interrupts = <0 12 IRQ_TYPE_EDGE_FALLING>; /* PL12 */ - keypad,num-rows = <6>; + keypad,num-rows = <12>; keypad,num-columns = <12>; linux,keymap = ; + MATRIX_KEY(5, 5, KEY_RIGHTALT) + + /* FN layer */ + MATRIX_KEY(6, 1, KEY_BACKSLASH) + MATRIX_KEY(6, 2, KEY_BACKSLASH) + MATRIX_KEY(6, 3, KEY_DOLLAR) + MATRIX_KEY(6, 4, KEY_EURO) + MATRIX_KEY(6, 5, KEY_GRAVE) + MATRIX_KEY(6, 6, KEY_GRAVE) + MATRIX_KEY(6, 7, KEY_MINUS) + MATRIX_KEY(6, 8, KEY_EQUAL) + MATRIX_KEY(6, 9, KEY_MINUS) + MATRIX_KEY(6, 10, KEY_EQUAL) + MATRIX_KEY(6, 11, KEY_DELETE) + + MATRIX_KEY(8, 0, KEY_SYSRQ) + MATRIX_KEY(8, 10, KEY_INSERT) + + MATRIX_KEY(9, 0, KEY_LEFTSHIFT) + MATRIX_KEY(9, 8, KEY_HOME) + MATRIX_KEY(9, 9, KEY_UP) + MATRIX_KEY(9, 10, KEY_END) + + MATRIX_KEY(10, 1, KEY_LEFTCTRL) + MATRIX_KEY(10, 6, KEY_LEFT) + MATRIX_KEY(10, 8, KEY_RIGHT) + MATRIX_KEY(10, 9, KEY_DOWN) + + MATRIX_KEY(11, 2, KEY_FN) + MATRIX_KEY(11, 3, KEY_LEFTALT) + MATRIX_KEY(11, 5, KEY_RIGHTALT)>; wakeup-source; }; };