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

Input: imx6ul_tsc - set glitch threshold by DTS property

Set the glitch threshold by DTS property and keep the existing default
behavior if the 'debounce-delay-us' is not present.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Link: https://lore.kernel.org/r/20250923143746.2857292-7-dario.binacchi@amarulasolutions.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Dario Binacchi and committed by
Dmitry Torokhov
5042e57d 3fccd1f9

+23 -2
+23 -2
drivers/input/touchscreen/imx6ul_tsc.c
··· 79 79 #define MEASURE_SIG_EN BIT(0) 80 80 #define VALID_SIG_EN BIT(8) 81 81 #define DE_GLITCH_MASK GENMASK(30, 29) 82 - #define DE_GLITCH_2 0x02 82 + #define DE_GLITCH_DEF 0x02 83 83 #define START_SENSE BIT(12) 84 84 #define TSC_DISABLE BIT(16) 85 85 #define DETECT_MODE 0x2 ··· 98 98 u32 pre_charge_time; 99 99 bool average_enable; 100 100 u32 average_select; 101 + u32 de_glitch; 101 102 102 103 struct completion completion; 103 104 }; ··· 206 205 basic_setting |= AUTO_MEASURE; 207 206 writel(basic_setting, tsc->tsc_regs + REG_TSC_BASIC_SETTING); 208 207 209 - debug_mode2 = FIELD_PREP(DE_GLITCH_MASK, DE_GLITCH_2); 208 + debug_mode2 = FIELD_PREP(DE_GLITCH_MASK, tsc->de_glitch); 210 209 writel(debug_mode2, tsc->tsc_regs + REG_TSC_DEBUG_MODE2); 211 210 212 211 writel(tsc->pre_charge_time, tsc->tsc_regs + REG_TSC_PRE_CHARGE_TIME); ··· 392 391 int tsc_irq; 393 392 int adc_irq; 394 393 u32 average_samples; 394 + u32 de_glitch; 395 395 396 396 tsc = devm_kzalloc(&pdev->dev, sizeof(*tsc), GFP_KERNEL); 397 397 if (!tsc) ··· 513 511 "touchscreen-average-samples (%u) must be 1, 4, 8, 16 or 32\n", 514 512 average_samples); 515 513 return -EINVAL; 514 + } 515 + 516 + err = of_property_read_u32(np, "debounce-delay-us", &de_glitch); 517 + if (err) { 518 + tsc->de_glitch = DE_GLITCH_DEF; 519 + } else { 520 + u64 cycles; 521 + unsigned long rate = clk_get_rate(tsc->tsc_clk); 522 + 523 + cycles = DIV64_U64_ROUND_UP((u64)de_glitch * rate, USEC_PER_SEC); 524 + 525 + if (cycles <= 0x3ff) 526 + tsc->de_glitch = 3; 527 + else if (cycles <= 0x7ff) 528 + tsc->de_glitch = 2; 529 + else if (cycles <= 0xfff) 530 + tsc->de_glitch = 1; 531 + else 532 + tsc->de_glitch = 0; 516 533 } 517 534 518 535 err = input_register_device(tsc->input);