Commit graph

15 commits

Author SHA1 Message Date
Sean Nyekjaer 25d496949f drivers: pwm: pwm_stm32: reset timer using RCC before initialization
If a timer is left running on an stm32mp1, (most likely) on the next run
the timer is stuck.
A simple timer reset before initialization fixes the issue.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
2023-07-20 10:36:10 +00:00
Kumar Gala 885087b328 drivers: pwm: Update drivers to use devicetree Kconfig symbol
Update pwm drivers to use DT_HAS_<compat>_ENABLED Kconfig symbol
to expose the driver and enable it by default based on devicetree.

We remove 'depend on' Kconfig for symbols that would be implied by
the devicetree node existing.

Signed-off-by: Kumar Gala <galak@kernel.org>
2022-07-22 07:50:44 -05:00
Gerard Marull-Paretas 6b81695946 drivers: pwm: stm32: fix timer clock calculation
Calculation of the timer clock was wrong for some F4/F7/H7 series.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-11-03 11:03:54 +01:00
Gerard Marull-Paretas 528a98ba3f drivers: pwm: stm32: refactor driver using LL API
The PWM drivers has been refactored using the HAL LL API. Not only that,
but the set pin_set function is now faster, as channel output compare is
just initialized if needed.

NOTE: Has been tested using H743zi board for now.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-06-19 15:18:50 +02:00
Gerard Marull-Paretas c6b1375400 drivers: pwm: stm32: remove remaining Kconfig instances
Following other drivers, Kconfig based instances are now entirely
removed. In order to do this change, PWM nodes in board DT files have
been given a pwm{N} label so that both:

- DT API checks such as #if DT_HAS_NODE(DT_NODELABEL(pwmN)) can be
  used (N being PWM instance number).
- DT references can be written as pwms = <&pwmN x y>; instead of
  pwms = <&{/soc/timers@XXXXXXXX/pwm} x y>;

This approach is also used on the Linux Kernel.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-05-05 10:52:51 -05:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson f46e391f06 kconfig: pwm: Remove redundant deps. and clean up a bit
- Remove redundant dependencies on the PWM symbol (which show up as
   PWM && PWM in the documentation). The 'source's in
   drivers/pwm/Kconfig are already within an 'if PWM' block.

 - Turn some repeated 'depends on FOO' into 'if FOO' blocks.

 - Turn some 'if FOO's that surround a single symbol into
   'depends on FOO'.

'if FOO' is equivalent to adding a 'depends on FOO' to each symbol
within the 'if'.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-03-01 13:50:06 -06:00
Ulf Magnusson f30b163624 drivers: pwm: Kconfig: Remove redundant 'default n' properties
Bool symbols implicitly default to 'n'.

A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though, and is
inconsistent.

This will make the auto-generated Kconfig documentation have "No
defaults. Implicitly defaults to n." as well, which is clearer than
'default n if ...'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2018-07-03 17:11:31 -04:00
Florian Vaussard 653d75cfba pwm: stm32: Add PWM fixup for STM32* and remove Kconfig options
Add fixup info for PWM nodes on STM32F0/F1/F3/F4/L4 and remove the
conflicting Kconfig symbols to fully switch STM32 PWM to device tree.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-06-12 03:54:26 -04:00
Florian Vaussard 20365bac0e pwm: stm32: Do not hardcode the prescalers
The prescalers are currently hardcoded and are not user-selectable. As a
result, the frequency of the timer can be inadequate to the task. For
instance, the frequency of the 16-bit timers (prescaler 10000) is
usually too low to correctly generate of PWM of a few kilohertz.

Hardcoded prescalers are replaced by Kconfigs so the user can choose at
compile time. The default value of each Kconfig matches the hardcoded
prescaler, so the change will be transparent.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-06-12 03:54:26 -04:00
Florian Vaussard f34e74dba2 pwm: stm32: Add support for all PWMs up to PWM20
All the PWM between 1 and 20 can be found on the STM32 depending on the
serie and the specific model. Add all the missing PWMs up to PWM20 to
plan for the future needs.

Tested on STM32L496 with available PWMs.

Signed-off-by: Florian Vaussard <florian.vaussard@gmail.com>
2018-06-12 03:54:26 -04:00
Erwin Rol d54aaa0326 drivers: pwm: stm32: use Kconfig to select HAL/LL sources
Use "select USE_STM32_HAL_TIM" to select the needed STM32 HAL files,
instead of editing ext/hal/st/stm32cube/CMakeLists.txt

Signed-off-by: Erwin Rol <erwin@erwinrol.com>
2018-01-23 08:46:16 -06:00
Ricardo Salveti 0dca1f5bd3 pwm: stm32: Add PWM 3 (TIM3)
Add support for TIM3 as it is widely available and pins available via
headers on several devices.

Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
2017-09-13 10:07:44 -05:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Erwan Gouriou 4827f2f386 pwm/stm32: add PWM driver for STM32 F1/F4/L4
Provide PWM driver for STM32 series F1/F4/L4.
Driver is ported on STM32Cube HAL and should support other STM32
series with minor updates.
Configuration is done so that PWM sample driver could be run on
all nucleo boards supporting PWM driver.

Change-Id: I6522a565451085df932e0eefd8404268380b5bfe
Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2016-12-06 10:31:46 -06:00