- Last edited one year ago ago
LPTIM Linux driver
1 Article purpose
This article introduces the LPTIM Linux® driver for the LPTIM internal peripheral:
- Which LPTIM features are supported by the driver
- How to configure, use and debug the driver
- What is the driver structure, and where the source code can be found.
2 Short description
- handles common resources (registers, clock)
- handles the PWM output channel (single channel)
IIO hardware trigger driver:
- handles hardware trigger sources (synchronously with PWM) for other internal peripherals such as ADC, DAC, DFSDM
- handles the quadrature encoder interface as well as the external event counter.
3.1 Kernel configuration
Enable the following configurations (as well as their dependencies):
Device Drivers ---> -> Multifunction device drivers ---> <*> Support for STM32 Low-Power Timer -> Pulse-width modulation (PWM) support ---> <*> STMicroelectronics STM32 PWM LP -> Industrial I/O support ---> -> Triggers - standalone ---> <*> STM32 Low-Power Timer Trigger -> Counter support ---> <*> STM32 LP Timer encoder counter driver
3.2 Device tree
Refer to the LPTIM device tree configuration article when configuring the LPTIM Linux kernel driver.
4 How to use
5 How to trace and debug
The LPTIM Linux driver can access LPTIM registers through REGMAP.
It comes with debugfs entries, which allow dumping registers:
$ cd /sys/kernel/debug/regmap $ ls 40004000.timer 40009000.timer $ cd 40009000.timer $ cat registers 000: 00000003 004: 00000000 008: 00000000 ...
It also comes with tracepoints:
$ cd /sys/kernel/debug/tracing $ cat available_events | grep regmap ... regmap:regmap_reg_read regmap:regmap_reg_write
6 Source code location
The LPTIM Linux driver is composed of:
- stm32-lptimer.c driver to handle common resources, such as registers and clock.
- pwm-stm32-lp.c driver to handle PWM channel
- stm32-lptimer-trigger.c driver to handle trigger sources for other internal peripherals
- stm32-lptimer-cnt.c driver to handle quadrature encoder and external event counter
- include/linux/mfd/stm32-lptimer.h and include/linux/iio/timer/stm32-lptim-trigger.h header files