deleted>Frq08988 mNo edit summary |
Registered User mNo edit summary |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
== Article purpose == | == Article purpose == | ||
This article introduces the LPTIM Linux<sup>®</sup> driver for the LPTIM internal peripheral<ref name="LPTIM internal peripheral">[[LPTIM internal peripheral]]</ref>: | This article introduces the LPTIM Linux<sup>®</sup> driver for the LPTIM internal peripheral<ref name="LPTIM internal peripheral">[[LPTIM internal peripheral]]</ref>: | ||
Line 13: | Line 4: | ||
* How to configure, use and debug the driver | * How to configure, use and debug the driver | ||
* What is the driver structure, and where the source code can be found. | * What is the driver structure, and where the source code can be found. | ||
{{ReviewsComments|-- NathalieS , Fabrice G<br />Article to be updated to be compliant with ecosystem v2.1.0 (BZ 95795), some example on ''clock event'' must be added}} | |||
== Short description == | == Short description == | ||
The ''LPTIM''<ref name="LPTIM internal peripheral"/> Linux driver (kernel space) is based on the [[PWM overview|PWM]] | The ''LPTIM''<ref name="LPTIM internal peripheral"/> Linux driver (kernel space) is based on the [[PWM overview|PWM]], [[IIO overview|IIO]] and <span style="color: {{STLightBlue}};">counter</span> frameworks. It provides several functionalities: | ||
'''MFD driver''': | '''MFD driver''': | ||
Line 23: | Line 16: | ||
'''IIO hardware trigger driver''': | '''IIO hardware trigger driver''': | ||
* handles hardware '''trigger sources''' (synchronously with PWM) for other internal peripherals such as ADC<ref name="adc_internal">[[ADC internal peripheral]]</ref>, DAC<ref name="dac_internal">[[DAC internal peripheral]]</ref>, DFSDM<ref name="dfsdm_internal">[[DFSDM internal peripheral]]</ref> | * handles hardware '''trigger sources''' (synchronously with PWM) for other internal peripherals such as ADC<ref name="adc_internal">[[ADC internal peripheral]]</ref>, DAC<ref name="dac_internal">[[DAC internal peripheral]]</ref>, DFSDM<ref name="dfsdm_internal">[[DFSDM internal peripheral]]</ref> | ||
''' | '''Counter driver''': | ||
* handles the '''quadrature encoder''' interface<ref name="quadrature_encoder">[https://en.wikipedia.org/wiki/Rotary_encoder#Incremental_encoder Incremental encoder overview]</ref> as well as the external event counter. | * handles the '''quadrature encoder''' interface<ref name="quadrature_encoder">[https://en.wikipedia.org/wiki/Rotary_encoder#Incremental_encoder Incremental encoder overview]</ref> as well as the external event counter. | ||
Line 38: | Line 31: | ||
Device Drivers ---> | Device Drivers ---> | ||
-> Multifunction device drivers ---> | -> Multifunction device drivers ---> | ||
<*> Support for STM32 | <*> Support for STM32 Low-Power Timer | ||
-> Pulse-width modulation (PWM) support ---> | -> Pulse-width modulation (PWM) support ---> | ||
<*> STMicroelectronics STM32 PWM LP | <*> STMicroelectronics STM32 PWM LP | ||
-> Industrial I/O support ---> | -> Industrial I/O support ---> | ||
-> Triggers - standalone ---> | -> Triggers - standalone ---> | ||
<*> STM32 | <*> STM32 Low-Power Timer Trigger | ||
-> Counter support ---> | |||
<*> STM32 LP Timer encoder counter driver | |||
</pre> | </pre> | ||
Line 85: | Line 78: | ||
* {{CodeSource | Linux kernel | drivers/pwm/pwm-stm32-lp.c | pwm-stm32-lp.c driver}} to handle PWM channel | * {{CodeSource | Linux kernel | drivers/pwm/pwm-stm32-lp.c | pwm-stm32-lp.c driver}} to handle PWM channel | ||
* {{CodeSource | Linux kernel | drivers/iio/trigger/stm32-lptimer-trigger.c | stm32-lptimer-trigger.c driver}} to handle trigger sources for other internal peripherals | * {{CodeSource | Linux kernel | drivers/iio/trigger/stm32-lptimer-trigger.c | stm32-lptimer-trigger.c driver}} to handle trigger sources for other internal peripherals | ||
* {{CodeSource | Linux kernel | drivers | * {{CodeSource | Linux kernel | drivers/counter/stm32-lptimer-cnt.c | stm32-lptimer-cnt.c driver}} to handle quadrature encoder and external event counter | ||
* {{CodeSource | Linux kernel | include/linux/mfd/stm32-lptimer.h}} and {{CodeSource | Linux kernel | include/linux/iio/timer/stm32-lptim-trigger.h}} header files | * {{CodeSource | Linux kernel | include/linux/mfd/stm32-lptimer.h}} and {{CodeSource | Linux kernel | include/linux/iio/timer/stm32-lptim-trigger.h}} header files | ||
==References== | ==References== | ||
<references /> | <references /> | ||
<noinclude> | |||
[[Category:Timers|1]] | |||
[[Category:IIO]] | |||
{{PublicationRequestId | 9230 | 2018-10-16 | AnneJ}} | |||
{{ArticleBasedOnModel | Linux driver article model}} | |||
</noinclude> |
Latest revision as of 11:34, 29 March 2021
1. Article purpose[edit source]
This article introduces the LPTIM Linux® driver for the LPTIM internal peripheral[1]:
- 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[edit source]
The LPTIM[1] Linux driver (kernel space) is based on the PWM, IIO and counter frameworks. It provides several functionalities:
MFD driver:
- handles common resources (registers, clock)
PWM driver:
- 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[2], DAC[3], DFSDM[4]
Counter driver:
- handles the quadrature encoder interface[5] as well as the external event counter.
3. Configuration[edit source]
3.1. Kernel configuration[edit source]
Activate the LPTIM[1] Linux driver in the kernel configuration using the Linux Menuconfig tool: Menuconfig or how to configure kernel.
Enable the following configurations (as well as their dependencies):
- CONFIG_MFD_STM32_LPTIMER
- CONFIG_PWM_STM32_LP
- CONFIG_IIO_STM32_LPTIMER_TRIGGER
- CONFIG_STM32_LPTIMER_CNT
PWM) support ---> <*> STMicroelectronics STM32 PWM LP -> Industrial I/O support ---> -> Triggers - standalone ---> <*> STM32 Low-Power Timer Trigger -> Counter support ---> <*> STM32 LP Timer encoder counter driverDevice Drivers ---> -> Multifunction device drivers ---> <*> Support for STM32 Low-Power Timer -> Pulse-width modulation (
3.2. Device tree[edit source]
Refer to the LPTIM device tree configuration article when configuring the LPTIM Linux kernel driver.
4. How to use[edit source]
How to use PWM with sysfs interface
How to set up a TIM or LPTIM trigger using the sysfs interface
How to use the quadrature encoder with the sysfs interface
5. How to trace and debug[edit source]
The LPTIM Linux driver can access LPTIM registers through REGMAP.
It comes with debugfs[6] 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[7]:
$ cd /sys/kernel/debug/tracing
$ cat available_events | grep regmap
...
regmap:regmap_reg_read
regmap:regmap_reg_write
6. Source code location[edit source]
The LPTIM Linux driver is composed of:
- Template:CodeSource to handle common resources, such as registers and clock.
- Template:CodeSource to handle PWM channel
- Template:CodeSource to handle trigger sources for other internal peripherals
- Template:CodeSource to handle quadrature encoder and external event counter
- Template:CodeSource and Template:CodeSource header files