Skip to content

Commit 31789f3

Browse files
Mattijs Korpershoekdtor
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent d6ed525 commit 31789f3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/input/keyboard/mt6779-keypad.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
#define MTK_KPD_DEBOUNCE 0x0018
1818
#define MTK_KPD_DEBOUNCE_MASK GENMASK(13, 0)
1919
#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)
2025
#define MTK_KPD_NUM_MEMS 5
2126
#define MTK_KPD_NUM_BITS 136 /* 4*32+8 MEM5 only use 8 BITS */
2227

@@ -161,6 +166,11 @@ static int mt6779_keypad_pdrv_probe(struct platform_device *pdev)
161166
regmap_write(keypad->regmap, MTK_KPD_DEBOUNCE,
162167
(debounce * (1 << 5)) & MTK_KPD_DEBOUNCE_MASK);
163168

169+
regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_ROW,
170+
MTK_KPD_SEL_ROWMASK(keypad->n_rows));
171+
regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_COL,
172+
MTK_KPD_SEL_COLMASK(keypad->n_cols));
173+
164174
keypad->clk = devm_clk_get(&pdev->dev, "kpd");
165175
if (IS_ERR(keypad->clk))
166176
return PTR_ERR(keypad->clk);

0 commit comments

Comments
 (0)