Skip to content

Commit 79aafdf

Browse files
William Breathitt Graygregkh
authored andcommitted
counter: microchip-tcb-capture: Fix undefined counter channel state on probe
commit c0c9c73434666dc99ee156b25e7e722150bee001 upstream. Hardware initialize of the timer counter channel does not occur on probe thus leaving the Count in an undefined state until the first function_write() callback is executed. Fix this by performing the proper hardware initialization during probe. Fixes: 106b104 ("counter: Add microchip TCB capture counter") Reported-by: Csókás Bence <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Link: https://lore.kernel.org/r/20250305-preset-capture-mode-microchip-tcb-capture-v1-1-632c95c6421e@kernel.org Signed-off-by: William Breathitt Gray <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e0d57d0 commit 79aafdf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

drivers/counter/microchip-tcb-capture.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,25 @@ static int mchp_tc_probe(struct platform_device *pdev)
369369
channel);
370370
}
371371

372+
/* Disable Quadrature Decoder and position measure */
373+
ret = regmap_update_bits(regmap, ATMEL_TC_BMR, ATMEL_TC_QDEN | ATMEL_TC_POSEN, 0);
374+
if (ret)
375+
return ret;
376+
377+
/* Setup the period capture mode */
378+
ret = regmap_update_bits(regmap, ATMEL_TC_REG(priv->channel[0], CMR),
379+
ATMEL_TC_WAVE | ATMEL_TC_ABETRG | ATMEL_TC_CMR_MASK |
380+
ATMEL_TC_TCCLKS,
381+
ATMEL_TC_CMR_MASK);
382+
if (ret)
383+
return ret;
384+
385+
/* Enable clock and trigger counter */
386+
ret = regmap_write(regmap, ATMEL_TC_REG(priv->channel[0], CCR),
387+
ATMEL_TC_CLKEN | ATMEL_TC_SWTRG);
388+
if (ret)
389+
return ret;
390+
372391
priv->tc_cfg = tcb_config;
373392
priv->regmap = regmap;
374393
counter->name = dev_name(&pdev->dev);

0 commit comments

Comments
 (0)