Skip to content

Commit c0c9c73

Browse files
author
William Breathitt Gray
committed
counter: microchip-tcb-capture: Fix undefined counter channel state on probe
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 <csokas.bence@prolan.hu> Closes: https://lore.kernel.org/all/bfa70e78-3cc3-4295-820b-3925c26135cb@prolan.hu/ Link: https://lore.kernel.org/r/20250305-preset-capture-mode-microchip-tcb-capture-v1-1-632c95c6421e@kernel.org Signed-off-by: William Breathitt Gray <wbg@kernel.org>
1 parent 8744dcd commit c0c9c73

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
@@ -368,6 +368,25 @@ static int mchp_tc_probe(struct platform_device *pdev)
368368
channel);
369369
}
370370

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

0 commit comments

Comments
 (0)