Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Input: mt6779-keypad - implement row/column selection

The MediaTek keypad has a total of 6 input rows and 6 input columns.
By default, rows/columns 0-2 are enabled.

This is controlled by the KP_SEL register:
- bits[9:4] control row selection
- bits[15:10] control column selection

Each bit enables the corresponding row/column number (e.g KP_SEL[4]
enables ROW0)

Depending on how the keypad is wired, this may result in wrong readings
of the keypad state.

Program the KP_SEL register to limit the key detection to n_rows,
n_cols we retrieve from the device tree.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Link: https://lore.kernel.org/r/20220707075236.126631-3-mkorpershoek@baylibre.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Mattijs Korpershoek and committed by
Dmitry Torokhov
31789f35 d6ed5258

+10
+10
drivers/input/keyboard/mt6779-keypad.c
··· 17 17 #define MTK_KPD_DEBOUNCE 0x0018 18 18 #define MTK_KPD_DEBOUNCE_MASK GENMASK(13, 0) 19 19 #define MTK_KPD_DEBOUNCE_MAX_MS 256 20 + #define MTK_KPD_SEL 0x0020 21 + #define MTK_KPD_SEL_COL GENMASK(15, 10) 22 + #define MTK_KPD_SEL_ROW GENMASK(9, 4) 23 + #define MTK_KPD_SEL_COLMASK(c) GENMASK((c) + 9, 10) 24 + #define MTK_KPD_SEL_ROWMASK(r) GENMASK((r) + 3, 4) 20 25 #define MTK_KPD_NUM_MEMS 5 21 26 #define MTK_KPD_NUM_BITS 136 /* 4*32+8 MEM5 only use 8 BITS */ 22 27 ··· 165 160 166 161 regmap_write(keypad->regmap, MTK_KPD_DEBOUNCE, 167 162 (debounce * (1 << 5)) & MTK_KPD_DEBOUNCE_MASK); 163 + 164 + regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_ROW, 165 + MTK_KPD_SEL_ROWMASK(keypad->n_rows)); 166 + regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_COL, 167 + MTK_KPD_SEL_COLMASK(keypad->n_cols)); 168 168 169 169 keypad->clk = devm_clk_get(&pdev->dev, "kpd"); 170 170 if (IS_ERR(keypad->clk))