Lines Matching full:counter
3 * STM32 Low-Power Timer Encoder and Counter driver
14 #include <linux/counter.h>
100 /* Setup LP timer encoder/counter and polarity, without prescaler */ in stm32_lptim_setup()
140 static int stm32_lptim_cnt_read(struct counter_device *counter, in stm32_lptim_cnt_read() argument
143 struct stm32_lptim_cnt *const priv = counter_priv(counter); in stm32_lptim_cnt_read()
156 static int stm32_lptim_cnt_function_read(struct counter_device *counter, in stm32_lptim_cnt_function_read() argument
160 struct stm32_lptim_cnt *const priv = counter_priv(counter); in stm32_lptim_cnt_function_read()
175 static int stm32_lptim_cnt_function_write(struct counter_device *counter, in stm32_lptim_cnt_function_write() argument
179 struct stm32_lptim_cnt *const priv = counter_priv(counter); in stm32_lptim_cnt_function_write()
198 static int stm32_lptim_cnt_enable_read(struct counter_device *counter, in stm32_lptim_cnt_enable_read() argument
202 struct stm32_lptim_cnt *const priv = counter_priv(counter); in stm32_lptim_cnt_enable_read()
214 static int stm32_lptim_cnt_enable_write(struct counter_device *counter, in stm32_lptim_cnt_enable_write() argument
218 struct stm32_lptim_cnt *const priv = counter_priv(counter); in stm32_lptim_cnt_enable_write()
239 static int stm32_lptim_cnt_ceiling_read(struct counter_device *counter, in stm32_lptim_cnt_ceiling_read() argument
243 struct stm32_lptim_cnt *const priv = counter_priv(counter); in stm32_lptim_cnt_ceiling_read()
250 static int stm32_lptim_cnt_ceiling_write(struct counter_device *counter, in stm32_lptim_cnt_ceiling_write() argument
254 struct stm32_lptim_cnt *const priv = counter_priv(counter); in stm32_lptim_cnt_ceiling_write()
274 static int stm32_lptim_cnt_action_read(struct counter_device *counter, in stm32_lptim_cnt_action_read() argument
279 struct stm32_lptim_cnt *const priv = counter_priv(counter); in stm32_lptim_cnt_action_read()
283 err = stm32_lptim_cnt_function_read(counter, count, &function); in stm32_lptim_cnt_action_read()
289 /* LP Timer acts as up-counter on input 1 */ in stm32_lptim_cnt_action_read()
318 static int stm32_lptim_cnt_action_write(struct counter_device *counter, in stm32_lptim_cnt_action_write() argument
323 struct stm32_lptim_cnt *const priv = counter_priv(counter); in stm32_lptim_cnt_action_write()
330 err = stm32_lptim_cnt_function_read(counter, count, &function); in stm32_lptim_cnt_action_write()
334 /* only set polarity when in counter mode (on input 1) */ in stm32_lptim_cnt_action_write()
398 /* LP timer without encoder (counter only) */
413 struct counter_device *counter; in stm32_lptim_cnt_probe() local
420 counter = devm_counter_alloc(&pdev->dev, sizeof(*priv)); in stm32_lptim_cnt_probe()
421 if (!counter) in stm32_lptim_cnt_probe()
423 priv = counter_priv(counter); in stm32_lptim_cnt_probe()
430 /* Initialize Counter device */ in stm32_lptim_cnt_probe()
431 counter->name = dev_name(&pdev->dev); in stm32_lptim_cnt_probe()
432 counter->parent = &pdev->dev; in stm32_lptim_cnt_probe()
433 counter->ops = &stm32_lptim_cnt_ops; in stm32_lptim_cnt_probe()
435 counter->counts = &stm32_lptim_enc_counts; in stm32_lptim_cnt_probe()
436 counter->num_signals = ARRAY_SIZE(stm32_lptim_cnt_signals); in stm32_lptim_cnt_probe()
438 counter->counts = &stm32_lptim_in1_counts; in stm32_lptim_cnt_probe()
439 counter->num_signals = 1; in stm32_lptim_cnt_probe()
441 counter->num_counts = 1; in stm32_lptim_cnt_probe()
442 counter->signals = stm32_lptim_cnt_signals; in stm32_lptim_cnt_probe()
446 ret = devm_counter_add(&pdev->dev, counter); in stm32_lptim_cnt_probe()
448 return dev_err_probe(&pdev->dev, ret, "Failed to add counter\n"); in stm32_lptim_cnt_probe()
459 /* Only take care of enabled counter: don't disturb other MFD child */ in stm32_lptim_cnt_suspend()
504 { .compatible = "st,stm32-lptimer-counter", },
512 .name = "stm32-lptimer-counter",
520 MODULE_ALIAS("platform:stm32-lptimer-counter");
521 MODULE_DESCRIPTION("STMicroelectronics STM32 LPTIM counter driver");
523 MODULE_IMPORT_NS(COUNTER);