Skip to content

Commit 5042e57

Browse files
passgatdtor
authored andcommitted
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>
1 parent 3fccd1f commit 5042e57

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

drivers/input/touchscreen/imx6ul_tsc.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
#define MEASURE_SIG_EN BIT(0)
8080
#define VALID_SIG_EN BIT(8)
8181
#define DE_GLITCH_MASK GENMASK(30, 29)
82-
#define DE_GLITCH_2 0x02
82+
#define DE_GLITCH_DEF 0x02
8383
#define START_SENSE BIT(12)
8484
#define TSC_DISABLE BIT(16)
8585
#define DETECT_MODE 0x2
@@ -98,6 +98,7 @@ struct imx6ul_tsc {
9898
u32 pre_charge_time;
9999
bool average_enable;
100100
u32 average_select;
101+
u32 de_glitch;
101102

102103
struct completion completion;
103104
};
@@ -205,7 +206,7 @@ static void imx6ul_tsc_set(struct imx6ul_tsc *tsc)
205206
basic_setting |= AUTO_MEASURE;
206207
writel(basic_setting, tsc->tsc_regs + REG_TSC_BASIC_SETTING);
207208

208-
debug_mode2 = FIELD_PREP(DE_GLITCH_MASK, DE_GLITCH_2);
209+
debug_mode2 = FIELD_PREP(DE_GLITCH_MASK, tsc->de_glitch);
209210
writel(debug_mode2, tsc->tsc_regs + REG_TSC_DEBUG_MODE2);
210211

211212
writel(tsc->pre_charge_time, tsc->tsc_regs + REG_TSC_PRE_CHARGE_TIME);
@@ -391,6 +392,7 @@ static int imx6ul_tsc_probe(struct platform_device *pdev)
391392
int tsc_irq;
392393
int adc_irq;
393394
u32 average_samples;
395+
u32 de_glitch;
394396

395397
tsc = devm_kzalloc(&pdev->dev, sizeof(*tsc), GFP_KERNEL);
396398
if (!tsc)
@@ -513,6 +515,25 @@ static int imx6ul_tsc_probe(struct platform_device *pdev)
513515
return -EINVAL;
514516
}
515517

518+
err = of_property_read_u32(np, "debounce-delay-us", &de_glitch);
519+
if (err) {
520+
tsc->de_glitch = DE_GLITCH_DEF;
521+
} else {
522+
u64 cycles;
523+
unsigned long rate = clk_get_rate(tsc->tsc_clk);
524+
525+
cycles = DIV64_U64_ROUND_UP((u64)de_glitch * rate, USEC_PER_SEC);
526+
527+
if (cycles <= 0x3ff)
528+
tsc->de_glitch = 3;
529+
else if (cycles <= 0x7ff)
530+
tsc->de_glitch = 2;
531+
else if (cycles <= 0xfff)
532+
tsc->de_glitch = 1;
533+
else
534+
tsc->de_glitch = 0;
535+
}
536+
516537
err = input_register_device(tsc->input);
517538
if (err) {
518539
dev_err(&pdev->dev,

0 commit comments

Comments
 (0)