On Wed, Dec 20, 2023 at 03:57:22PM +0100, Fabrice Gasnier wrote: > This is a precursor patch to support capture channels on all possible > channels and stm32 timer types. Original driver was intended to be used > only as quadrature encoder and simple counter on internal clock. > > So, add a check on encoder capability, so the driver may be probed for > timer instances without encoder feature. This way, all timers may be used > as simple counter on internal clock, starting from here. > > Encoder capability is retrieved by using the timer index (originally in > stm32-timer-trigger driver and dt-bindings). The need to keep backward > compatibility with existing device tree lead to parse aside trigger node. > > Signed-off-by: Fabrice Gasnier <fabrice.gasnier@xxxxxxxxxxx> > --- > Changes in v3: > - New patch split from: > "counter: stm32-timer-cnt: populate capture channels and check encoder" > - return -EOPNOTSUPP when encoder function isn't supported by the timer > instance. > --- > drivers/counter/stm32-timer-cnt.c | 55 +++++++++++++++++++++++++++++++ > 1 file changed, 55 insertions(+) > > diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c > index bf2726dd7f12..6933d42b16bf 100644 > --- a/drivers/counter/stm32-timer-cnt.c > +++ b/drivers/counter/stm32-timer-cnt.c > @@ -11,6 +11,7 @@ > #include <linux/mfd/stm32-timers.h> > #include <linux/mod_devicetable.h> > #include <linux/module.h> > +#include <linux/of.h> > #include <linux/pinctrl/consumer.h> > #include <linux/platform_device.h> > #include <linux/types.h> > @@ -38,6 +39,8 @@ struct stm32_timer_cnt { > u32 max_arr; > bool enabled; > struct stm32_timer_regs bak; > + bool has_encoder; > + u32 idx; This idx value is only used temporarily to determine whether the device has support for encoder mode. Do we really need to store it indefinitely here? > +static int stm32_timer_cnt_probe_encoder(struct platform_device *pdev, This function uses 'pdev' only to access 'dev'. It'll be better to pass a reference to 'dev' directly instead. William Breathitt Gray
Attachment:
signature.asc
Description: PGP signature