[PATCH 08/10] Input: mt6779-keypad - enable keypad clock before programming registers

Lee Jones lee at kernel.org
Mon Nov 23 10:31:14 PST 2026


mt6779_keypad_pdrv_probe() writes the debounce and matrix selection
registers over MMIO before acquiring and enabling the "kpd" clock via
devm_clk_get_enabled().

When the keypad clock is gated off at boot or its clock provider defers
probe, accessing unclocked keypad MMIO registers can trigger a bus abort
or silently drop the configuration writes.

Acquire and enable the "kpd" clock before accessing the keypad
registers.

Fixes: f28af984e771 ("Input: mt6779-keypad - add MediaTek keypad driver")
Closes: https://sashiko.dev/#/bug/linux-fc15622a-407a-48b2-88db-195cdb311dbf
Cc: stable at vger.kernel.org
Signed-off-by: Lee Jones <lee at kernel.org>
---
 drivers/input/keyboard/mt6779-keypad.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/input/keyboard/mt6779-keypad.c b/drivers/input/keyboard/mt6779-keypad.c
index 60e6ad97cf59..a9f62f02439e 100644
--- a/drivers/input/keyboard/mt6779-keypad.c
+++ b/drivers/input/keyboard/mt6779-keypad.c
@@ -195,6 +195,10 @@ static int mt6779_keypad_pdrv_probe(struct platform_device *pdev)
 
 	input_set_capability(keypad->input_dev, EV_MSC, MSC_SCAN);
 
+	keypad->clk = devm_clk_get_enabled(&pdev->dev, "kpd");
+	if (IS_ERR(keypad->clk))
+		return PTR_ERR(keypad->clk);
+
 	regmap_write(keypad->regmap, MTK_KPD_DEBOUNCE,
 		     (debounce * (1 << 5)) & MTK_KPD_DEBOUNCE_MASK);
 
@@ -208,10 +212,6 @@ static int mt6779_keypad_pdrv_probe(struct platform_device *pdev)
 	regmap_update_bits(keypad->regmap, MTK_KPD_SEL, MTK_KPD_SEL_COL,
 			   MTK_KPD_SEL_COLMASK(keypad->n_cols));
 
-	keypad->clk = devm_clk_get_enabled(&pdev->dev, "kpd");
-	if (IS_ERR(keypad->clk))
-		return PTR_ERR(keypad->clk);
-
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
-- 
2.56.1.750.gf70dc682cf-goog




More information about the linux-arm-kernel mailing list