summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <wbg@kernel.org>2025-03-05 19:01:19 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-07 10:06:37 +0200
commit52eed361c25087ceabd3c0feb6cb820593611336 (patch)
treee6b1d96e9512350b9e7ed4e0fb4ea6339509680e
parentfa15592e9d92a32a1377f2707ba0e0b7f962ac87 (diff)
downloadlinux-52eed361c25087ceabd3c0feb6cb820593611336.tar.gz
linux-52eed361c25087ceabd3c0feb6cb820593611336.tar.bz2
linux-52eed361c25087ceabd3c0feb6cb820593611336.zip
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: 106b104137fd ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/counter/microchip-tcb-capture.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/counter/microchip-tcb-capture.c b/drivers/counter/microchip-tcb-capture.c
index b3e615cbd2ca..461f57f66631 100644
--- a/drivers/counter/microchip-tcb-capture.c
+++ b/drivers/counter/microchip-tcb-capture.c
@@ -368,6 +368,25 @@ static int mchp_tc_probe(struct platform_device *pdev)
channel);
}
+ /* Disable Quadrature Decoder and position measure */
+ ret = regmap_update_bits(regmap, ATMEL_TC_BMR, ATMEL_TC_QDEN | ATMEL_TC_POSEN, 0);
+ if (ret)
+ return ret;
+
+ /* Setup the period capture mode */
+ ret = regmap_update_bits(regmap, ATMEL_TC_REG(priv->channel[0], CMR),
+ ATMEL_TC_WAVE | ATMEL_TC_ABETRG | ATMEL_TC_CMR_MASK |
+ ATMEL_TC_TCCLKS,
+ ATMEL_TC_CMR_MASK);
+ if (ret)
+ return ret;
+
+ /* Enable clock and trigger counter */
+ ret = regmap_write(regmap, ATMEL_TC_REG(priv->channel[0], CCR),
+ ATMEL_TC_CLKEN | ATMEL_TC_SWTRG);
+ if (ret)
+ return ret;
+
priv->tc_cfg = tcb_config;
priv->regmap = regmap;
counter->name = dev_name(&pdev->dev);