Commit graph zephyr/drivers/pwm
Author SHA1 Message Date
Marek Maškarinec
501b79fb05 drivers: nrf-sw-pwm: Fix missing comma in iterator macro
The comma was removed during the migration in commit ad1e5ac253. All
usages of this driver inside the Zephyr tree use only one channel,
which doesn't trigger the issue.

Signed-off-by: Marek Maškarinec <marek@mrms.cz>
2026-07-07 09:50:50 +02:00
2bcb7bbff7 drivers: pwm: add support for the CH32V Advanced-control Timer (ADTM)
The ADTM is a superset of the GPTM and has the same core register
layout. See section 11.2.2 of the CH32V003RM for details on the
differences.

Use the same technique as the GD32 driver, i.e. use the same basic
driver with tweaks based on the features.

Add the common 3x GTPM and 1x ADTM Devicetree and pinctrl entries for
the 20x and 30x series and the extra 1x GPTM for the CH32V208 used in
linkw. I can follow up with the other chips in a separate PR.

Tested on the ch32v006evt and linkw by running
`samples/basic/blinky_pwm` and `tests/drivers/pwm/pwm_api` and
checking the output with a logic analyser.

Signed-off-by: Michael Hope <michaelh@juju.nz>
2026-07-04 11:40:54 -04:00
Sylvio Alves
0352972bbf drivers: pwm: esp32: lock irqs around ledc channel update
The low-speed channel update latches the preceding register writes and
can stall for milliseconds if an interrupt preempts the sequence. Lock
interrupts around the start and stop sequences to keep them atomic.

Signed-off-by: Sylvio Alves <sylviojalves@gmail.com>
2026-07-03 13:57:21 -04:00
Fabrice DJIATSA
50cd54c80f drivers: pwm: stm32: guard slave trigger against missing LL_TIM_TS_ macros
Some STM32 series (e.g. WB0) do not provide all LL_TIM_TS_ITRx macros,
causing build failures when the timer is configured in disabled slave
mode. Introduce PWM_SLAVE_TRIGGER() which conditionally expands to the
LL_TIM_TS_* token only when slave mode is actually enabled, and falls
back to 0 otherwise.

Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
2026-07-01 15:28:35 +01:00
Matthias Plöger
94dca129c0 drivers: pwm: stm32: Avoid slave mode reg reconfiguration by capture
- Only modify salve mode registers when not in 4-channel capture mode
- Add compile time check for not compatible configuration.
  Capture support is only allowed if:
    - No slave mode is selected
    - or capture runs in four_channel_capture_support mode

Signed-off-by: Matthias Plöger <matthias.ploeger@phoenixcontact.com>
2026-06-24 07:37:02 -04:00
Matthias Plöger
596df51bdc drivers: pwm: stm32: Add slave mode support
- Add new dts bindings for slave mode and trigger selection
- Add exception for LP timers (not supported)
- Implement configuration of master mode during device init

Signed-off-by: Matthias Plöger <matthias.ploeger@phoenixcontact.com>
2026-06-24 07:37:02 -04:00
Jacob Wienecke
c59df938a6 drivers: pwm: mcux_sctimer: guard counter start
The PM_DEVICE_ACTION_RESUME handler started the SCT counter
unconditionally. When RESUME runs before the first pwm_set_cycles()
no period match or counter limit event exists yet, so the counter
free-runs across its full 32-bit range. By the time a channel is
configured, COUNT has climbed past the period match installed as the
counter limit; since the limit only fires on COUNT == match, the
counter never resets and the output is stranded until a full 32-bit
wrap. Guard the start with pwm_channel_active so the counter is only
started once at least one channel has been configured.

Signed-off-by: Jacob Wienecke <jacob.wienecke@nxp.com>
2026-06-22 18:02:21 -04:00
Michael Zimmermann
8a7ae0bed1 modules: hal_silabs: rename gecko kconfigs
- Kconfigs in modules/ should not define configs with an SOC_ prefix.
  Furthermore, these options are SDK specific, not SoC specific.
- The simplicity_sdk configs do the same.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-06-17 08:05:45 +02:00
Sylvio Alves
1df3062e3a drivers: esp32: align with updated hal_espressif hal apis
Adopt the new HAL/LL interfaces: ADC_LL_* macros,
esp_clk_tree_* clock helpers, and rng_ll_* entropy reads
across the adc, i2c, pwm, mdio and entropy drivers.

Update the Radio blobs to latest version.

Update linkers to include new sleep cache calls.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-11 15:03:44 -04:00
Raffael Rostagno
9b6b63ce0c drivers: mcpwm: esp32: PM support
Add PM support for ESP32 devices for MCPWM driver.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2026-06-10 13:12:00 +02:00
Johan Eklund
2537f9888c drivers: pwm: mcux_sctimer: configure initial output state from DT
The NXP SCTimer's outInitState field defines the output levels applied at
initialization, before any PWM channel is configured. Needed for active
low loads to not flicker at startup

Signed-off-by: Johan Eklund <Johan@meck.se>
2026-06-08 19:01:05 +02:00
Felix Wang
86682c7af5 drivers: pwm: mcux: gate channel A/B/X capture by SoC feature macros
The capture-related code in the FlexPWM driver unconditionally
references kPWM_CaptureA*Flag / kPWM_CaptureB*Flag and CVAL2..CVAL5
registers, which do not exist on SoCs whose FlexPWM only supports input
capture on the X channel (for example MCXA153, where
FSL_FEATURE_PWM_HAS_CAPTURE_ON_CHANNELA/B are 0 and only CHANNELX is 1).
This caused a build failure as soon as CONFIG_PWM_CAPTURE was enabled
on such SoCs.

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2026-06-08 13:54:42 +02:00
Felix Wang
1259cd2121 drivers: pwm: mcux_ctimer: add PWM capture support
Implement the Zephyr PWM capture API using the CTIMER
capture-clears-timer feature.

One capture channel is configured to fire an IRQ on the active
edge while ENCC/SELCC clears TC+PC on the opposite (or same) edge so
that CR latches the period or pulse width directly with no software
subtraction. The INPUTMUX is configured at driver init from a new
inputmux-connections DT property that lists <captsel-index, connection>
pairs.

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2026-06-08 13:54:42 +02:00
Felix Wang
898dac9f3d drivers: pwm: mcux_ctimer: fix PWM output polarity in set_cycles
CTIMER PWM mode emits LOW for MR[pulse_channel] ticks then HIGH for the
remainder of the period, so PWM_POLARITY_NORMAL must map pulse_cycles to
(period - pulse_cycles), not pass it through unchanged.

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2026-06-08 13:54:42 +02:00
Raffael Rostagno
caa27e425a drivers: pwm_ledc: esp32: Sleep retention
Add sleep retention support for LEDC PWM driver. When peripheral
power down is enabled for light sleep, register data is lost,
so REGDMA backup is needed to mantein peripheral operational.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2026-05-29 22:05:37 +02:00
Thomas Decker
a6eb598d80 driver: pwm: stm32: Add access to input capture prescaler via flags
Adds STM32 specific flags to set the input capture prescaler to 2, 4 or 8.

Signed-off-by: Thomas Decker <decker@jb-lighting.de>
2026-05-28 11:05:18 +01:00
Fabrice DJIATSA
eb9c50c97e drivers: pwm: stm32: Missing LL_TIM_TRGO_UPDATE for WB0x series
LL_TIM_TRGO_UPDATE isn't yet implemented on STM32WB0x series.

Exclude WB0x series from using LL_TIM_TRGO_UPDATE.

This is addressed by testing HAS_MASTERMODE_SUPPORT that is disabled
for platforms not defining LL_TIM_TRGO_UPDATE.

Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
2026-05-21 06:31:31 -04:00
Davide Di Lello
58f192e773 drivers: infineon: Update copyright for Infineon
Update structure of the copyright

Signed-off-by: Davide Di Lello <Davide.Dilello@Infineon.com>
2026-05-15 23:27:34 +02:00
Davide Di Lello
82741b2614 drivers: infineon: Update copyright for Infineon
Update structure of the copyright

Signed-off-by: Davide Di Lello <Davide.Dilello@Infineon.com>
2026-05-12 22:19:02 +02:00
Sylvio Alves
36ac2822f5 soc: espressif: sync with latest hal_espressif
Update hal_espressif revision and adapt drivers and linker
scripts to the new HAL APIs.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-05-12 17:16:50 +02:00
Nhut Nguyen
ce0ab92159 drivers: pwm: renesas: Fix missing last period in event sample
Fix missing last period when running samples/drivers/pwm/event. The last
period was incomplete because it is stopped immediately before the new
period became effective.

Signed-off-by: Nhut Nguyen <nhut.nguyen.kc@renesas.com>
2026-05-12 09:00:20 +02:00
Nhut Nguyen
4084433d1b drivers: pwm: renesas: Add support for PWM event API
Implement PWM event API for Renesas RA

Signed-off-by: Nhut Nguyen <nhut.nguyen.kc@renesas.com>
2026-05-12 09:00:20 +02:00
Srinivas Edireswarapu
ae3473eb51 drivers: pwm: mchp_xec: fix switch-case break indentation
Fix misaligned break statements in pwm_xec_pm_action() switch-case
block to match the case indentation level.

Signed-off-by: Srinivas Edireswarapu <srinivas.edireswarapu@microchip.com>
2026-05-11 21:02:18 -05:00
Srinivas Edireswarapu
2e5597b09d drivers: pwm: mchp_xec: refactor for encoded DT properties
Refactor the Microchip XEC PWM driver to use DTS-encoded PCR
property via soc_xec_pcr_sleep_en_clear(), replacing per-SoC
ifdefs for PCR init. Move PCR enable before pinctrl apply in
the init sequence.

Signed-off-by: Srinivas Edireswarapu <srinivas.edireswarapu@microchip.com>
2026-05-11 21:02:18 -05:00
Michał Stasiak
e547706430 drivers: pwm: pwm_nrfx: handle uninitialized period cycles
If first PWM sequence is set to 100% glitch free duty
cycle, period_cycles will remain uninitialized while
all used channels will use PWM. If following
sequences request non-100% duty cycle, period
cycles will have to be changed. Improve error
condition to allow changing period cycles for
running PWM if these are equal to 0.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2026-05-08 14:42:52 +01:00
Matthias Plöger
82acd3ef37 drivers: pwm: stm32: refactor ARR preload generation into device init
Avoids set of ARR value without enabled preload once counter is enabled.

Signed-off-by: Matthias Plöger <matthias.ploeger@phoenixcontact.com>
2026-05-07 18:04:01 -05:00
Matthias Plöger
1853c1a106 drivers: pwm: stm32: Avoid update generation in master-update mode
When the following conditions are met:
- center aligned mode
- trigger generation on update event
an additional update event is avoided during channel activation.
This may cause (depending on the up/down counting direction) a
de-synchronisation between pwm polarity and generated trigger.
Problematic  when e.g. the adc should trigger during high- and
low phase of a pwm signal.

Signed-off-by: Matthias Plöger <matthias.ploeger@phoenixcontact.com>
2026-05-07 18:04:01 -05:00
Yuzhuo Liu
a6f802b9b1 drivers: pwm: add Realtek Bee series driver
Add PWM driver support for Realtek Bee series SoCs,
including RTL87x2G and RTL8752H.

This driver supports:
- Pulse width modulation output
- Period and pulse width configuration
- Polarity inversion

Signed-off-by: Yuzhuo Liu <yuzhuo_liu@realsil.com.cn>
2026-05-01 09:50:16 +02:00
Stefan Gloor
ece9ac4213 drivers: pwm: add generic gpio bitbang pwm
Add a generic software PWM driver as a fallback
when no dedicated hardware PWM pins are available.
This implementation leverages a single hardware
timer interrupt as a time base to derive an
arbitrary number of software-controlled PWM channels.
The period is the same for all channels.

This enables use of LED brightness and blink APIs.
Tested on Nucleo H563ZI with this overlay:

/ {
    status_leds: status_leds {
        compatible = "pwm-leds";

        status_led_1: status_led_1 {
            pwms = <&soft_pwm 0 PWM_MSEC(10) PWM_POLARITY_NORMAL>;
            label = "1";
        };
    };

    soft_pwm: soft_pwm {
        compatible = "zephyr,pwm-bitbang";
        #pwm-cells = <3>;
        timer = <&tim6_counter>;
        pwm-gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>;
    };
};

&timers6 {
    status = "okay";
    st,prescaler = <24999>;
    tim6_counter: counter {
        status = "okay";
    };
};

Assisted-by: GitHub Copilot:claude-opus-4.6
Signed-off-by: Stefan Gloor <stefan.gloor@siemens.com>
2026-04-28 00:26:06 +01:00
Fin Maaß
bf9d688deb drivers: pwm: litex: use mem_addr_t
use mem_addr_t for register addresses.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2026-04-15 17:15:46 -04:00
Erwan Gouriou
5ac8a0e2ae Revert "drivers: pwm: add support for enabling DMA requests"
This reverts commit 311a841620.
+ related changes done in 841e4d4597

Proposed API change result in vendor specific details of the DMA leaking
into application code, which prevents usage with portable code.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2026-03-31 13:58:55 -05:00
Pisit Sawangvonganan
f5512a6907 drivers: fix typo in (mipi_dbi, misc, mm, mspi, pcie, ptp_clock, pwm)
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/mipi_dbi`
- `drivers/misc`
- `drivers/mm`
- `drivers/mspi`
- `drivers/pcie`
- `drivers/ptp_clock`
- `drivers/pwm`

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2026-03-27 20:21:24 -04:00
Raffael Rostagno
37aef33e64 pm: drivers: pwm_ledc: esp32: Add device PM
Add code for device PM to the driver.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2026-03-23 17:37:48 -05:00
John Batch
c3f8820e95 drivers: pwm: infineon: Adding support for PWM events
Adds implementation of the PWM_EVENT api options.  The Infineon TCPWM
Module supports the PWM_EVENT_TYPE_COMPARE_CAPTURE and
PWM_EVENT_TYPE_PERIOD events.

Assisted-by: GitHub Copilot:claude-opus-4.6
Signed-off-by: John Batch <john.batch@infineon.com>
2026-03-23 10:18:00 +01:00
Sylvio Alves
06be42d138 drivers: pwm: add esp32c5 support
Extend the ESP32 LEDC PWM driver to support ESP32-C5. Clear the
gamma RAM fade function on SoCs that have it to prevent stale
fade parameters from affecting duty cycle output.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-03-19 14:53:05 -05:00
Guillaume Gautier
1235b49fba drivers: pwm: stm32: update pwm driver for stm32 hal2
In STM32 HAL2, some define have been renamed.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-03-19 14:52:01 -05:00
Christopher Smith
b30a5a9f11 drivers: pwm: esp32: add pinctrl initialization for mcpwm capture
The ESP32 MCPWM driver does not initialize the pinctrl configuration if
only the capture units of MCPWM are used and no other MCPWM outputs are
used. This leads to pwm capture requests timing out. Fix this by applying
the pinctrl configuration during module initialization.

Signed-off-by: Christopher Smith <christophersmith107@gmail.com>
2026-03-18 17:46:32 -05:00
William Markezana
d547042bf9 drivers: bflb: extend shared drivers with BL70XL SoC support
Add CONFIG_SOC_SERIES_BL70XL to preprocessor conditionals across
existing Bouffalo Lab drivers that share register-compatible code
paths with BL60x/BL70x:

- cache: L1C flush-enable workaround applies to BL70XL
- flash: XIP address defines, L1C wrap, QPI JEDEC ID support
- gpio: BL70XL includes, fix BIT() usage for pin set/clear
- i2c: clock source calculation
- serial: UART clock divider, guard UART1 (BL70XL has only UART0)
- spi: GLB address and FIFO size, clock calculation
- syscon: efuse SAHB clock selection
- input: IR receiver pin mapping and clock divider

Signed-off-by: William Markezana <william.markezana@gmail.com>
2026-03-18 17:40:26 -05:00
Felix Wang
d1e8dca27c drivers: pwm: Fix capture support bug
Refactor the PWM capture interrupt handler to properly support all
three capture channels (A, B, and X).

Clear capture FIFOs by reading CVAL registers during enable_capture

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2026-03-18 12:47:33 +09:00
Felix Wang
1b3c4aef72 drivers: pwm: mcux: Guard input filter functions with feature check
Add feature check to ensure these functions are only called when the
hardware supports input filter capture registers.

Update device tree binding documentation to clarify that the
input-filter-count and input-filter-period properties only take
effect when the capture input filter register is available.

Signed-off-by: Felix Wang <fei.wang_3@nxp.com>
2026-03-18 12:47:33 +09:00
Jacob Wienecke
a983ea808e pwm: mcux_sctimer: apply pinctrl in PM
Apply PINCTRL_STATE_SLEEP on suspend and PINCTRL_STATE_DEFAULT
on resume. If a sleep pinctrl state is defined in the board DTS,
pins will be reconfigured on suspend. If not defined, the call
is a no-op.

Signed-off-by: Jacob Wienecke <jacob.wienecke@nxp.com>
2026-03-18 11:03:32 +09:00
Cherrence Sarip
79e6e32f79 drivers: pwm: add support for MAX2221X pwm
Implements PWM driver support for the MAX22216/MAX22217 device.
This driver integrates with the Zephyr PWM API and uses the parent
MFD device to perform register access.

Signed-off-by: Cherrence Sarip <cherrence.sarip@analog.com>
2026-03-16 10:09:16 -04:00
Ryan Wiebe
7a5b256d66 driver: pwm: max32: Added support for PWM Events
Max32 PWM already has built-in support for interrupts at the end of
each PWM period so added baseline support for the PERIOD event type
in CONFIG_PWM_EVENT. Updated PWM Event sample to support
Max32672EvKit.

Signed-off-by: Ryan Wiebe <ryan.wiebe@analog.com>
2026-03-14 05:59:33 +01:00
Sylvio Alves
c64a74e711 espressif: adapt to hal_espressif IDF master sync
Adapt all Espressif SoC and driver code to the updated
hal_espressif module synced with IDF master branch.

Main changes:
- clock control: delegate peripheral clock gating to HAL
  layer using new clock/reset APIs
- SPI/GDMA: adapt to restructured DMA HAL with new channel
  allocation and configuration interfaces
- ethernet: add RMII clock configuration and PHY management
- GPIO: simplify using direct HAL function calls
- flash: adapt to updated SPI flash HAL interfaces
- linker scripts: update IRAM/DRAM mappings for new HAL
  object files
- DTS: fix ESP32-S2 PSRAM dcache1 address to match actual
  MMU mapping region (0x3f800000 DRAM1 instead of 0x3f500000
  DPORT which lacks 8-bit access capability)
- west.yml: update hal_espressif revision

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-03-13 11:38:18 +01:00
Vincent Surkijn
311a841620 drivers: pwm: add support for enabling DMA requests
Extend the PWM API with optional API functions for enabling DMA requests

Possible solution for #88670

Signed-off-by: Vincent Surkijn <vincent.surkijn@siemens.com>
2026-03-11 11:38:01 +01:00
Alberto Escolar Piedras
a30ac3bc35 drivers: pwm: stm32: Fix builds without mastermode support
Correct an #if which otherwise is always true, so we do not
refer to a function which does not exist otherwise.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-03-05 04:44:58 +01:00
Manojkumar Konisetty
9cfc87619a drivers: pwm: infineon: add dedicated PWM driver for PSoC4
Add PWM driver for the Infineon PSoC4 family.
This includes SoC-specific register configurations, API calls,
and hardware instance mapping required for PSoC4 compatibility.

Signed-off-by: Surya Prakash T <suryat@aerlync.com>
Signed-off-by: Manojkumar Konisetty <manoj@aerlync.com>
Signed-off-by: Sayooj K Karun <sayooj@aerlync.com>
2026-03-05 04:42:21 +01:00
Matthias Plöger
bb16624662 drivers: pwm: stm32: Add trigger output configuration
- Add new dts binding for configurable master mode
- Add exception for LP timers (not supported)
- Add required defines for configuration options
- Implement configuration of master mode during device init

Signed-off-by: Matthias Plöger <matthias.ploeger@phoenixcontact.com>
2026-02-25 13:04:05 +01:00
Mathieu Choplain
a11688fab5 drivers: *: stm32: don't check if clock device is ready
If the clock device (i.e., RCC) failed to initialize, we have bigger
problems than trying to call clock_control_{off,on,configure} on it.
Don't bother checking to save some footprint.

Signed-off-by: Mathieu Choplain <mathieu.choplain-ext@st.com>
2026-02-13 18:59:16 +00:00
Pieter De Gendt
f91399d2f5 drivers: pwm: Put driver APIs into iterable section
Use the DEVICE_API macro to put the PWM driver APIs into the correct
iterable section.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2026-02-12 14:33:20 +00:00