Version Bump

This commit is contained in:
Gerben Jan Dijkman 2021-09-12 17:25:06 +02:00
parent a4bdc1b081
commit d8d7940f2b
6 changed files with 6918 additions and 1530 deletions

View File

@ -1,6 +1,6 @@
DIST all-5.13.5.patch 15071574 BLAKE2B f0b44888b216a60bb12a920a170ffb8ee705e357b82b0cacd58551e2d0e257c0f4419c34976263dc062335bb37f4b3a7418f3d9674e601fd8adda88bacad97d6 SHA512 046f42a5c8fe6477cdda82f47a07093ea51cf26b231b1c58230885954b7ecab9faa9eb72ac3c0cb1603dd6ca2b5b0d76421de6d2c3c05a0bee3ca6e080bfa084 DIST all-5.13.5.patch 15071574 BLAKE2B f0b44888b216a60bb12a920a170ffb8ee705e357b82b0cacd58551e2d0e257c0f4419c34976263dc062335bb37f4b3a7418f3d9674e601fd8adda88bacad97d6 SHA512 046f42a5c8fe6477cdda82f47a07093ea51cf26b231b1c58230885954b7ecab9faa9eb72ac3c0cb1603dd6ca2b5b0d76421de6d2c3c05a0bee3ca6e080bfa084
DIST all-5.14.1.patch 15063858 BLAKE2B dead0428f722a0af4488162b071850f3261198022f966183f0ae5aa5cf802388ea7fd7d1a75046c3ef9f3f67d4760a0fd89cd5a33e9a4546b48a974ca60e3a1b SHA512 f084775d5506450abf89e6e86284a6e23b973c65d5992f9702cd74e60b2551091db2eb8fb63a50dec1393bf5ff38afa27c552dd0cfc70e55815dce0b050dd7e8 DIST all-5.14.2.patch 15063858 BLAKE2B dead0428f722a0af4488162b071850f3261198022f966183f0ae5aa5cf802388ea7fd7d1a75046c3ef9f3f67d4760a0fd89cd5a33e9a4546b48a974ca60e3a1b SHA512 f084775d5506450abf89e6e86284a6e23b973c65d5992f9702cd74e60b2551091db2eb8fb63a50dec1393bf5ff38afa27c552dd0cfc70e55815dce0b050dd7e8
DIST linux-5.13.tar.xz 119297284 BLAKE2B 9c4c12e2394dec064adff51f7ccdf389192eb27ba7906db5eda543afe3d04afca6b9ea0848a057571bf2534eeb98e1e3a67734deff82c0d3731be205ad995668 SHA512 a8edf97e9d38a49f1be2bde1e29ad96274bb2c6f7e8a2bebaa1161dd4df9cabcbaec4ff644c45bee94f86ae47725087d6deed0cd954209cec717621d137db85e DIST linux-5.13.tar.xz 119297284 BLAKE2B 9c4c12e2394dec064adff51f7ccdf389192eb27ba7906db5eda543afe3d04afca6b9ea0848a057571bf2534eeb98e1e3a67734deff82c0d3731be205ad995668 SHA512 a8edf97e9d38a49f1be2bde1e29ad96274bb2c6f7e8a2bebaa1161dd4df9cabcbaec4ff644c45bee94f86ae47725087d6deed0cd954209cec717621d137db85e
DIST linux-5.14.tar.xz 120669872 BLAKE2B 0047f5aaa3940dff97f4055ef544faafbbb5282128e6afe21d2f47d8dc8c395806a17016febfa050117d16f59e74b882cb8b9c5011d68f119c230d0a4d120524 SHA512 8e4f3ec3d36f774280f75dc7b004a43e09417af58f12e9c9f8348976659d4cfda7ad905f306f43fed66a27922e5c45db22e46bbfa7a0b9f365012380de3b6f64 DIST linux-5.14.tar.xz 120669872 BLAKE2B 0047f5aaa3940dff97f4055ef544faafbbb5282128e6afe21d2f47d8dc8c395806a17016febfa050117d16f59e74b882cb8b9c5011d68f119c230d0a4d120524 SHA512 8e4f3ec3d36f774280f75dc7b004a43e09417af58f12e9c9f8348976659d4cfda7ad905f306f43fed66a27922e5c45db22e46bbfa7a0b9f365012380de3b6f64
DIST patch-5.13.5.xz 473120 BLAKE2B a0dd9f3f972a16de87f0d2d8daa7f5d35b27314d22597a28f471cdbe6cedfa7d4bf69e41504d6a9b9d4c1f085146604394747771185dd0a09276cfd92820b4a8 SHA512 1e4eb575775ccbc2e88b34b902a75562e49d6dfb4699dadd5b41fff9db8c2bc994d946d1e60f6320f48ef233aa721d3725582d4ec57458f2293da9a85806c7b1 DIST patch-5.13.5.xz 473120 BLAKE2B a0dd9f3f972a16de87f0d2d8daa7f5d35b27314d22597a28f471cdbe6cedfa7d4bf69e41504d6a9b9d4c1f085146604394747771185dd0a09276cfd92820b4a8 SHA512 1e4eb575775ccbc2e88b34b902a75562e49d6dfb4699dadd5b41fff9db8c2bc994d946d1e60f6320f48ef233aa721d3725582d4ec57458f2293da9a85806c7b1
DIST patch-5.14.1.xz 4708 BLAKE2B 334d56ba26abc0d29432c27a31fefff332d9b134899b6f0d5fdeadaf68c3bf95eaeba37a9500eb3c245ae2eea70786c55056586ce747277e9f2be16697ceab73 SHA512 409108139ba2842d100d69e47d88eee87bea58c210a84e242c82aae48fe4bc57ccd0a507c4a0ecb791d0a2962f46cda3ba900f728a9b6856e986bff018a2d19c DIST patch-5.14.2.xz 8376 BLAKE2B 0fd1b718801661f5fe70866b0301bdcdaa4c2c0ca75aefcc20d4edb7439326cbc2aa1a0f78dd105bc7939f52107aca032f0e6e43d39c077e4f784220d0a8f752 SHA512 b8f181cf5d19e5206e4e0524a1bef5639346b71d002523bfd65e3a2fc2b914fa979c381c8a613c062503160510f31c003f712773cb6945497aa3eba71595c697

View File

@ -0,0 +1,172 @@
From 2423aac2d6f5db55da99e11fd799ee66fe6f54c6 Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
Date: Mon, 9 Aug 2021 19:30:18 -0500
Subject: [PATCH] Input: kb151 - Add support for the FN layer
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
.../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 0bdc6eceec6099..68f5730cf164c7 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(0, 0, KEY_ESC)
MATRIX_KEY(0, 1, KEY_1)
@@ -612,7 +612,37 @@
MATRIX_KEY(4, 9, KEY_LEFTBRACE)
MATRIX_KEY(5, 2, KEY_FN)
MATRIX_KEY(5, 3, KEY_LEFTALT)
- MATRIX_KEY(5, 5, KEY_RIGHTALT)>;
+ 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;
};
};
diff --git a/drivers/input/keyboard/kb151.c b/drivers/input/keyboard/kb151.c
index 595275d4f9d96f..bb6250efe93419 100644
--- a/drivers/input/keyboard/kb151.c
+++ b/drivers/input/keyboard/kb151.c
@@ -29,6 +29,7 @@ struct kb151 {
u8 row_shift;
u8 rows;
u8 cols;
+ u8 fn_state;
u8 buf_swap;
u8 buf[];
};
@@ -55,7 +56,7 @@ static void kb151_update(struct i2c_client *client)
return;
}
- dev_info(dev, "%02x | %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
+ dev_dbg(dev, "%02x | %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
new_buf[0], new_buf[1], new_buf[2], new_buf[3], new_buf[4], new_buf[5],
new_buf[6], new_buf[7], new_buf[8], new_buf[9], new_buf[10], new_buf[11],
new_buf[12]);
@@ -65,8 +66,6 @@ static void kb151_update(struct i2c_client *client)
crc, new_buf[0]);
return;
}
- dev_info(dev, "Good scan data (%02x == %02x)\n",
- crc, new_buf[0]);
for (col = 0; col < kb151->cols; ++col) {
u8 old = *(++old_buf);
@@ -74,14 +73,20 @@ static void kb151_update(struct i2c_client *client)
u8 changed = old ^ new;
for (row = 0; row < kb151->rows; ++row) {
- int code = MATRIX_SCAN_CODE(row, col, kb151->row_shift);
u8 pressed = new & BIT(row);
+ u8 map_row = row + (kb151->fn_state ? kb151->rows : 0);
+ int code = MATRIX_SCAN_CODE(map_row, col, kb151->row_shift);
if (!(changed & BIT(row)))
continue;
dev_dbg(&client->dev, "row %u col %u %sed\n",
- row, col, pressed ? "press" : "releas");
+ map_row, col, pressed ? "press" : "releas");
+ if (keymap[code] == KEY_FN) {
+ dev_dbg(&client->dev, "FN is now %s\n",
+ pressed ? "pressed" : "released");
+ kb151->fn_state = pressed;
+ } else
input_report_key(kb151->input, keymap[code], pressed);
}
}
@@ -151,7 +156,7 @@ static int kb151_probe(struct i2c_client *client)
struct device *dev = &client->dev;
u8 info[KB151_MATRIX_SIZE + 1];
unsigned int kb_rows, kb_cols;
- unsigned int rows, cols;
+ unsigned int map_rows, map_cols;
struct kb151 *kb151;
int ret;
@@ -168,20 +173,20 @@ static int kb151_probe(struct i2c_client *client)
info[KB151_FW_REVISION] & 0xf,
info[KB151_FW_FEATURES]);
- ret = matrix_keypad_parse_properties(dev, &rows, &cols);
+ ret = matrix_keypad_parse_properties(dev, &map_rows, &map_cols);
if (ret)
return ret;
kb_rows = info[KB151_MATRIX_SIZE] & 0xf;
kb_cols = info[KB151_MATRIX_SIZE] >> 4;
- if (rows > kb_rows || cols != kb_cols) {
+ if (map_rows != 2 * kb_rows || map_cols != kb_cols) {
dev_err(dev, "Keyboard matrix is %ux%u, but key map is %ux%u\n",
- kb_rows, kb_cols, rows, cols);
+ kb_rows, kb_cols, map_rows, map_cols);
return -EINVAL;
}
/* Allocate two buffers, and include space for the CRC. */
- kb151 = devm_kzalloc(dev, struct_size(kb151, buf, 2 * (cols + 1)), GFP_KERNEL);
+ kb151 = devm_kzalloc(dev, struct_size(kb151, buf, 2 * (kb_cols + 1)), GFP_KERNEL);
if (!kb151)
return -ENOMEM;
@@ -189,9 +194,9 @@ static int kb151_probe(struct i2c_client *client)
crc8_populate_msb(kb151->crc_table, KB151_CRC8_POLYNOMIAL);
- kb151->row_shift = get_count_order(cols);
- kb151->rows = rows;
- kb151->cols = cols;
+ kb151->row_shift = get_count_order(kb_cols);
+ kb151->rows = kb_rows;
+ kb151->cols = kb_cols;
kb151->input = devm_input_allocate_device(dev);
if (!kb151->input)
@@ -207,7 +212,7 @@ static int kb151_probe(struct i2c_client *client)
__set_bit(EV_REP, kb151->input->evbit);
- ret = matrix_keypad_build_keymap(NULL, NULL, rows, cols,
+ ret = matrix_keypad_build_keymap(NULL, NULL, map_rows, map_cols,
NULL, kb151->input);
if (ret)
return dev_err_probe(dev, ret, "Failed to build keymap\n");

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,377 @@
From d1d849cae12db71aa81ceedaedc1b17a34790367 Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
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 <samuel@sholland.org>
---
.../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 4ede9fe66020c9..0bdc6eceec6099 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 = <MATRIX_KEY(0, 0, KEY_ESC)
+ MATRIX_KEY(0, 1, KEY_1)
+ MATRIX_KEY(0, 2, KEY_2)
+ MATRIX_KEY(0, 3, KEY_3)
+ MATRIX_KEY(0, 4, KEY_4)
+ MATRIX_KEY(0, 5, KEY_5)
+ MATRIX_KEY(0, 6, KEY_6)
+ MATRIX_KEY(0, 7, KEY_7)
+ MATRIX_KEY(0, 8, KEY_8)
+ MATRIX_KEY(0, 9, KEY_9)
+ MATRIX_KEY(0, 10, KEY_0)
+ MATRIX_KEY(0, 11, KEY_BACKSPACE)
+ MATRIX_KEY(1, 0, KEY_TAB)
+ MATRIX_KEY(1, 1, KEY_Q)
+ MATRIX_KEY(1, 2, KEY_W)
+ MATRIX_KEY(1, 3, KEY_E)
+ MATRIX_KEY(1, 4, KEY_R)
+ MATRIX_KEY(1, 5, KEY_T)
+ MATRIX_KEY(1, 6, KEY_Y)
+ MATRIX_KEY(1, 7, KEY_U)
+ MATRIX_KEY(1, 8, KEY_I)
+ MATRIX_KEY(1, 9, KEY_O)
+ MATRIX_KEY(1, 10, KEY_P)
+ MATRIX_KEY(1, 11, KEY_ENTER)
+ MATRIX_KEY(2, 0, KEY_LEFTMETA)
+ MATRIX_KEY(2, 1, KEY_A)
+ MATRIX_KEY(2, 2, KEY_S)
+ MATRIX_KEY(2, 3, KEY_D)
+ MATRIX_KEY(2, 4, KEY_F)
+ MATRIX_KEY(2, 5, KEY_G)
+ MATRIX_KEY(2, 6, KEY_H)
+ MATRIX_KEY(2, 7, KEY_J)
+ MATRIX_KEY(2, 8, KEY_K)
+ MATRIX_KEY(2, 9, KEY_L)
+ MATRIX_KEY(2, 10, KEY_SEMICOLON)
+ MATRIX_KEY(3, 0, KEY_LEFTSHIFT)
+ MATRIX_KEY(3, 1, KEY_Z)
+ MATRIX_KEY(3, 2, KEY_X)
+ MATRIX_KEY(3, 3, KEY_C)
+ MATRIX_KEY(3, 4, KEY_V)
+ MATRIX_KEY(3, 5, KEY_B)
+ MATRIX_KEY(3, 6, KEY_N)
+ MATRIX_KEY(3, 7, KEY_M)
+ MATRIX_KEY(3, 8, KEY_COMMA)
+ MATRIX_KEY(3, 9, KEY_DOT)
+ MATRIX_KEY(3, 10, KEY_SLASH)
+ MATRIX_KEY(4, 1, KEY_LEFTCTRL)
+ MATRIX_KEY(4, 4, KEY_SPACE)
+ MATRIX_KEY(4, 6, KEY_APOSTROPHE)
+ MATRIX_KEY(4, 8, KEY_RIGHTBRACE)
+ MATRIX_KEY(4, 9, KEY_LEFTBRACE)
+ MATRIX_KEY(5, 2, KEY_FN)
+ MATRIX_KEY(5, 3, KEY_LEFTALT)
+ MATRIX_KEY(5, 5, KEY_RIGHTALT)>;
+ wakeup-source;
+ };
};
&i2s2 {
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig
index 40a070a2e7f5b7..0259e9133f4692 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
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile
index 1d689fdd5c00f9..87fda7b961913a 100644
--- a/drivers/input/keyboard/Makefile
+++ b/drivers/input/keyboard/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_KEYBOARD_IMX) += imx_keypad.o
obj-$(CONFIG_KEYBOARD_IMX_SC_KEY) += imx_sc_key.o
obj-$(CONFIG_KEYBOARD_HP6XX) += jornada680_kbd.o
obj-$(CONFIG_KEYBOARD_HP7XX) += jornada720_kbd.o
+obj-$(CONFIG_KEYBOARD_KB151) += kb151.o
obj-$(CONFIG_KEYBOARD_LKKBD) += lkkbd.o
obj-$(CONFIG_KEYBOARD_LM8323) += lm8323.o
obj-$(CONFIG_KEYBOARD_LM8333) += lm8333.o
diff --git a/drivers/input/keyboard/kb151.c b/drivers/input/keyboard/kb151.c
new file mode 100644
index 00000000000000..595275d4f9d96f
--- /dev/null
+++ b/drivers/input/keyboard/kb151.c
@@ -0,0 +1,246 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (C) 2021 Samuel Holland <samuel@sholland.org>
+
+#include <linux/crc8.h>
+#include <linux/i2c.h>
+#include <linux/input/matrix_keypad.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/pm_wakeirq.h>
+
+#define KB151_CRC8_POLYNOMIAL 0x07
+
+#define KB151_DEVICE_ID_HI 0x00
+#define KB151_DEVICE_ID_HI_VALUE 0x4b
+#define KB151_DEVICE_ID_LO 0x01
+#define KB151_DEVICE_ID_LO_VALUE 0x42
+#define KB151_FW_REVISION 0x02
+#define KB151_FW_FEATURES 0x03
+#define KB151_MATRIX_SIZE 0x06
+#define KB151_SCAN_CRC 0x07
+#define KB151_SCAN_DATA 0x08
+#define KB151_SYS_CONFIG 0x20
+#define KB151_SYS_CONFIG_DISABLE_SCAN BIT(0)
+
+struct kb151 {
+ struct input_dev *input;
+ u8 crc_table[CRC8_TABLE_SIZE];
+ u8 row_shift;
+ u8 rows;
+ u8 cols;
+ u8 buf_swap;
+ u8 buf[];
+};
+
+static void kb151_update(struct i2c_client *client)
+{
+ struct kb151 *kb151 = i2c_get_clientdata(client);
+ unsigned short *keymap = kb151->input->keycode;
+ struct device *dev = &client->dev;
+ size_t buf_len = kb151->cols + 1;
+ u8 *old_buf = kb151->buf;
+ u8 *new_buf = kb151->buf;
+ int col, crc, ret, row;
+
+ if (kb151->buf_swap)
+ old_buf += buf_len;
+ else
+ new_buf += buf_len;
+
+ ret = i2c_smbus_read_i2c_block_data(client, KB151_SCAN_CRC,
+ buf_len, new_buf);
+ if (ret != buf_len) {
+ dev_err(dev, "Failed to read scan data: %d\n", ret);
+ return;
+ }
+
+ dev_info(dev, "%02x | %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
+ new_buf[0], new_buf[1], new_buf[2], new_buf[3], new_buf[4], new_buf[5],
+ new_buf[6], new_buf[7], new_buf[8], new_buf[9], new_buf[10], new_buf[11],
+ new_buf[12]);
+ crc = crc8(kb151->crc_table, new_buf + 1, kb151->cols, CRC8_INIT_VALUE);
+ if (crc != new_buf[0]) {
+ dev_err(dev, "Bad scan data (%02x != %02x)\n",
+ crc, new_buf[0]);
+ return;
+ }
+ dev_info(dev, "Good scan data (%02x == %02x)\n",
+ crc, new_buf[0]);
+
+ for (col = 0; col < kb151->cols; ++col) {
+ u8 old = *(++old_buf);
+ u8 new = *(++new_buf);
+ u8 changed = old ^ new;
+
+ for (row = 0; row < kb151->rows; ++row) {
+ int code = MATRIX_SCAN_CODE(row, col, kb151->row_shift);
+ u8 pressed = new & BIT(row);
+
+ if (!(changed & BIT(row)))
+ continue;
+
+ dev_dbg(&client->dev, "row %u col %u %sed\n",
+ row, col, pressed ? "press" : "releas");
+ input_report_key(kb151->input, keymap[code], pressed);
+ }
+ }
+ input_sync(kb151->input);
+
+ kb151->buf_swap = !kb151->buf_swap;
+}
+
+static int kb151_open(struct input_dev *input)
+{
+ struct i2c_client *client = input_get_drvdata(input);
+ struct device *dev = &client->dev;
+ int ret, val;
+
+ ret = i2c_smbus_read_byte_data(client, KB151_SYS_CONFIG);
+ if (ret < 0) {
+ dev_err(dev, "Failed to read config: %d\n", ret);
+ return ret;
+ }
+
+ val = ret & ~KB151_SYS_CONFIG_DISABLE_SCAN;
+ ret = i2c_smbus_write_byte_data(client, KB151_SYS_CONFIG, val);
+ if (ret) {
+ dev_err(dev, "Failed to write config: %d\n", ret);
+ return ret;
+ }
+
+ kb151_update(client);
+
+ enable_irq(client->irq);
+
+ return 0;
+}
+
+static void kb151_close(struct input_dev *input)
+{
+ struct i2c_client *client = input_get_drvdata(input);
+ struct device *dev = &client->dev;
+ int ret, val;
+
+ disable_irq(client->irq);
+
+ ret = i2c_smbus_read_byte_data(client, KB151_SYS_CONFIG);
+ if (ret < 0) {
+ dev_err(dev, "Failed to read config: %d\n", ret);
+ return;
+ }
+
+ val = ret | KB151_SYS_CONFIG_DISABLE_SCAN;
+ ret = i2c_smbus_write_byte_data(client, KB151_SYS_CONFIG, val);
+ if (ret) {
+ dev_err(dev, "Failed to write config: %d\n", ret);
+ }
+}
+
+static irqreturn_t kb151_irq_thread(int irq, void *data)
+{
+ struct i2c_client *client = data;
+
+ kb151_update(client);
+
+ return IRQ_HANDLED;
+}
+
+static int kb151_probe(struct i2c_client *client)
+{
+ struct device *dev = &client->dev;
+ u8 info[KB151_MATRIX_SIZE + 1];
+ unsigned int kb_rows, kb_cols;
+ unsigned int rows, cols;
+ struct kb151 *kb151;
+ int ret;
+
+ ret = i2c_smbus_read_i2c_block_data(client, 0, sizeof(info), info);
+ if (ret != sizeof(info))
+ return ret;
+
+ if (info[KB151_DEVICE_ID_HI] != KB151_DEVICE_ID_HI_VALUE ||
+ info[KB151_DEVICE_ID_LO] != KB151_DEVICE_ID_LO_VALUE)
+ return -ENODEV;
+
+ dev_info(dev, "Found KB151 with firmware %d.%d (features=%#x)\n",
+ info[KB151_FW_REVISION] >> 4,
+ info[KB151_FW_REVISION] & 0xf,
+ info[KB151_FW_FEATURES]);
+
+ ret = matrix_keypad_parse_properties(dev, &rows, &cols);
+ if (ret)
+ return ret;
+
+ kb_rows = info[KB151_MATRIX_SIZE] & 0xf;
+ kb_cols = info[KB151_MATRIX_SIZE] >> 4;
+ if (rows > kb_rows || cols != kb_cols) {
+ dev_err(dev, "Keyboard matrix is %ux%u, but key map is %ux%u\n",
+ kb_rows, kb_cols, rows, cols);
+ return -EINVAL;
+ }
+
+ /* Allocate two buffers, and include space for the CRC. */
+ kb151 = devm_kzalloc(dev, struct_size(kb151, buf, 2 * (cols + 1)), GFP_KERNEL);
+ if (!kb151)
+ return -ENOMEM;
+
+ i2c_set_clientdata(client, kb151);
+
+ crc8_populate_msb(kb151->crc_table, KB151_CRC8_POLYNOMIAL);
+
+ kb151->row_shift = get_count_order(cols);
+ kb151->rows = rows;
+ kb151->cols = cols;
+
+ kb151->input = devm_input_allocate_device(dev);
+ if (!kb151->input)
+ return -ENOMEM;
+
+ input_set_drvdata(kb151->input, client);
+
+ kb151->input->name = client->name;
+ kb151->input->phys = "kb151/input0";
+ kb151->input->id.bustype = BUS_I2C;
+ kb151->input->open = kb151_open;
+ kb151->input->close = kb151_close;
+
+ __set_bit(EV_REP, kb151->input->evbit);
+
+ ret = matrix_keypad_build_keymap(NULL, NULL, rows, cols,
+ NULL, kb151->input);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to build keymap\n");
+
+ ret = devm_request_threaded_irq(dev, client->irq,
+ NULL, kb151_irq_thread,
+ IRQF_ONESHOT | IRQF_NO_AUTOEN,
+ client->name, client);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to request IRQ\n");
+
+ ret = input_register_device(kb151->input);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to register input\n");
+
+ return 0;
+}
+
+static const struct of_device_id kb151_of_match[] = {
+ { .compatible = "pine64,kb151" },
+ { }
+};
+MODULE_DEVICE_TABLE(of, kb151_of_match);
+
+static struct i2c_driver kb151_driver = {
+ .probe_new = kb151_probe,
+ .driver = {
+ .name = "kb151",
+ .of_match_table = kb151_of_match,
+ },
+};
+module_i2c_driver(kb151_driver);
+
+MODULE_AUTHOR("Samuel Holland <samuel@sholland.org>");
+MODULE_DESCRIPTION("Pine64 KB151 keyboard driver");
+MODULE_LICENSE("GPL");

View File

@ -9,7 +9,7 @@ ETYPE="sources"
inherit kernel-2 inherit kernel-2
detect_version detect_version
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86" KEYWORDS="~arm64"
# Copyright 1999-2021 Gentoo Authors # Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2 # Distributed under the terms of the GNU General Public License v2
@ -33,7 +33,14 @@ PATCHES=(
${FILESDIR}/0011-dts-pinetab-hardcode-mmc-numbers.patch ${FILESDIR}/0011-dts-pinetab-hardcode-mmc-numbers.patch
${FILESDIR}/0107-quirk-kernel-org-bug-210681-firmware_rome_error.patch ${FILESDIR}/0107-quirk-kernel-org-bug-210681-firmware_rome_error.patch
${FILESDIR}/0177-leds-gpio-make-max_brightness-configurable.patch ${FILESDIR}/0177-leds-gpio-make-max_brightness-configurable.patch
${FILESDIR}/panic-led-5.12.patch ${FILESDIR}/panic-led-5.12.patch
# keyboard
${FILESDIR}/d1d849cae12db71aa81ceedaedc1b17a34790367.patch
${FILESDIR}/2423aac2d6f5db55da99e11fd799ee66fe6f54c6.patch
# LRU
${FILESDIR}/Multigenerational-LRU-Framework.patch
) )
src_prepare() { src_prepare() {
@ -60,3 +67,4 @@ pkg_postinst() {
pkg_postrm() { pkg_postrm() {
kernel-2_pkg_postrm kernel-2_pkg_postrm
} }