Commit graph

533 commits

Author SHA1 Message Date
Gerard Marull-Paretas 95b56cdffd drivers: pwm: remove _pin from API calls
In a first place, the PWM API operates on "channels", not "pins". While
the API calls could have been changed by _channel, this patch takes the
approach of just dropping _pin. The main reason is that all API calls
operate by definition on a channel basis, so it is a bit redundant to
make this part of the name. Because the `_dt` variants of the calls are
going to be introduced soon, the change to `_channels` + `_dt` would
make API function names quite long.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas fbf73334f3 drivers: pwm: make all drivers use channel variable name
The variable indicating the PWM channel is now names "channel" instead
of "pwm", adjust all drivers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas 6f39b08343 drivers: pwm: gecko: fix access to timer register
The timer registers are accessible via the device config field, driver
code was wrong in one case (pwm is the variable indicating PWM channel).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas aa37dedcaf drivers: pwm: ite_it8xxx2: remove wrong ARG_UNUSED
The pwm arg is used in the function, so placing ARG_UNUSED is wrong.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Gerard Marull-Paretas c11516ae90 drivers: pwm: ite_it8xxx2: add missing braces
Multiple if/else blocks had missing braces, add them as this violates
Zephyr coding guidelines.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-28 11:29:38 +02:00
Andrzej Głąbek 5609bc48dd drivers: pwm_nrf5_sw: Add support for PWM_POLARITY_INVERTED flag
Add support for inverting of PWM channel outputs in the pwm_nrf5_sw
driver by properly handling the `PWM_POLARITY_INVERTED` flag.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-22 09:43:26 +02:00
Andrzej Głąbek c23a449bfb drivers: pwm_nrf5_sw: Treat pwm parameter as PWM channel, not SoC pin
Align with other PWM drivers and treat the `pwm` parameter (described
ambiguously as "PWM pin") of the `pwm_pin_set_cycles` function as a PWM
channel, not an SoC pin. This will also make the driver consistent with
the `pwm-cells` property definition in the "nordic,nrf-sw-pwm" binding
and with related `DT_PWMS_*` macros.
The change described above requires also providing a way to specify
SoC pins that are to be assigned to the PWM channels. Hence, the commit
introduces in the "nordic,nrf-sw-pwm" binding the `channel-gpios`
property that replaces the `channel-count` one.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-22 09:43:26 +02:00
Andrzej Głąbek e7a075f460 drivers: pwm_nrfx: Add support for PWM_POLARITY_INVERTED flag
Add support for inverting of PWM channel outputs in the pwm_nrfx driver
by properly handling the `PWM_POLARITY_INVERTED` flag.
The dts properties that were used so far for inverting of the outputs
("nordic,invert" and "chX-inverted") are kept as they are needed for
setting of the initial polarity, i.e. for setting the inactive state
of the outputs before any PWM signal generation is requested for them.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-22 09:43:26 +02:00
Andrzej Głąbek dbdbc79b36 drivers: pwm_nrfx: Treat pwm parameter as PWM channel, not SoC pin
Align with other PWM drivers and treat the `pwm` parameter (described
ambiguously as "PWM pin") of the `pwm_pin_set_cycles` function as a PWM
channel, not an SoC pin. This will also make the driver consistent with
the `pwm-cells` property definition in the "nordic,nrf-pwm" binding
and with related `DT_PWMS_*` macros.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-22 09:43:26 +02:00
Georgij Cernysiov 3650664875 drivers: pwm: stm32: support counter modes
Adds support for different timer counter modes.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-04-15 11:59:16 -07:00
Georgij Cernysiov 366bf47c27 drivers: pwm: stm32: remove obvious comments
Removes obvious comments from the PWM
configuration struct.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
2022-04-15 11:59:16 -07:00
Hu Zhenyu 2824696d11 dts: mec172xevb_assy6906: Add pwm-0 alias to mec172xevb dts file
Enable tests/drivers/pwm/pwm_api test case on both west and twister

Signed-off-by: Hu Zhenyu <zhenyu.hu@intel.com>
2022-04-13 12:02:46 -05:00
Andrzej Głąbek 42275c263b drivers: pwm_nrf5_sw: Use the PPI FORK feature when available
This way, when RTC is used as the generator, one PPI channel per each
configured PWM channel can be saved.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-12 09:51:53 +02:00
Andrzej Głąbek d683ad0300 drivers: pwm_nrf5_sw: Correctly use all channels provided by generator
Use compare channel 0 in the generator for handling the PWM period.
This way all other channels offered by the generator can be easily
used for handling pulses on particular PWM channels.
So far the driver allowed to configure more than 3 channels for certain
TIMER instances, but since channel 3 was always used for the period,
the generation could not work in such setups.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-12 09:51:53 +02:00
Andrzej Głąbek f73618906d drivers: pwm_nrf5_sw: Correctly use allocated GPIOTE channels
The driver improperly uses the PWM channel index to reference
the GPIOTE channel to be used for the PWM signal generation.
Consequently, the PWM signal on a given channel can be correctly
generated only if both those indexes are by chance the same.
Fix this by switching to use the stored index of the actually
allocated GPIOTE channel.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-12 09:51:53 +02:00
Gerard Marull-Paretas 8ff797b850 drivers: pwm: litex: remove redundant config 'helper'
All these sort of helpers were removed from tree a while ago, this one
was missed as it uses a custom name.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-07 09:35:05 +02:00
Gerard Marull-Paretas e3fde6b01a drivers: pwm: sifive: remove redundant checks
If dev was null, caller would have faulted before since dev->api needs
to be accessed before reaching this point. Also, a well-defined device
will never have a NULL dev->config.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-07 09:35:05 +02:00
Gerard Marull-Paretas ccc12be0a5 drivers: pwm: return -ENOTSUP if inactive level is not supported
The API spec states that calling pin_set() with period set to 0 is
equivalent to set the PWM channel to an inactive level. Some drivers
treat this input as invalid (-EINVAL), however, it's an unsupported
feature. Maybe it's due to copy&paste effect? This changes error message
to be clear and changes return value to -ENOTSUP for this case.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-07 09:35:05 +02:00
Gerard Marull-Paretas 0c908706fb drivers: pwm: remove duplicated pulse > period checks
The API call checks for this condition before calling the pin_set driver
OP call, so drivers don't have to do this check now.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-04-07 09:35:05 +02:00
Daniel DeGrasse 415b2bdac0 drivers: pwm: pwm_mcux_sctimer: Add pinctrl support for lpc pwm
add pinctrl support for lpc sctimer pwm driver

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-04-06 20:57:22 -07:00
Shawn Nematbakhsh c74526919d soc: riscv: sifive-freedom: Get coreclk and peripheral clock from DTS.
Rather than specify input clock for each peripheral individually, instead
specify the relevant clocks in DTS.

This will enable easier support for non-default coreclk on fe310 in a
follow-up CL.

Signed-off-by: Shawn Nematbakhsh <shawn@rivosinc.com>
2022-04-05 12:00:03 +02:00
Andrzej Głąbek 586e26e8fc soc: nrf: Use data from DTS to populate HAS_HW_NRF_* Kconfig options
Instead of selecting appropriate HAS_HW_NRF_* options for particular
nRF SoCs (and simulated nRF52 target), set their values basing on
information from devicetree.
Correct also semantics of those options so that they are set only when
a corresponding DT node is enabled. This allows using them directly in
Kconfig dependencies of Zephyr drivers for nRF peripherals. Update
appropriately these dependencies.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-04-02 15:14:38 +02:00
Francois Ramu 90d1644a10 drivers: pwm: stm32 can initialize the PWM complementary output
If the dts defines the PWM complementary output, then the OCN
must be init in place of the OC state and polarity.
This is an exclusive setting for this pin.
The channel in LL_TIM_OC_SetPolarity can be the complementary one.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-03-31 10:28:47 +02:00
Daniel DeGrasse dbb4ad8eb1 drivers: pwm: enable pinctrl for nxp imx_pwm driver
Enable pinctrl for nxp imx_pwm driver

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-03-25 15:47:54 -05:00
Gerson Fernando Budke 8c51ad6c6f drivers: pwm: Add sam0 support to pinctrl
This add support to pinctrl at Atmel sam0 tcc pwm driver. It updates
all boards with new pinctrl groups format and drop pinmux entries.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2022-03-24 15:45:37 -07:00
Gerson Fernando Budke dc172849fa drivers: pwm: Update sam pwm driver to use pinctrl
This update Atmel sam pwm driver to use pinctrl driver and API. It
updates all boards with new pinctrl groups format. In addition this
remove all remaining manual pinmux at board level.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2022-03-24 15:45:37 -07:00
Jordan Yates c064006ecc drivers: pwm: test driver
Add a dummy driver for the `vnd,pwm` compatible to allow compilation of
drivers utilising PWM when running "build_all" tests.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2022-03-24 12:56:28 +01:00
Filip Kokosinski 38f38e0be8 boards: FE310-based boards: transition to pinctrl driver
This commit makes the transition from the pinmux driver to the pinctrl
driver. It also modifies UART, SPI and I2C drivers used in FE310-based
boards to use the new pinctrl API.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2022-03-24 10:46:34 +01:00
Daniel DeGrasse c29b602675 drivers: pwm: add pinctrl support to kinetis tpm driver
add pinctrl support for kinetis tpm driver

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-03-22 12:36:04 +01:00
Daniel DeGrasse 9b9450d8f3 drivers: pwm: add pinctrl support for mcux PWT driver
Enable pinctrl support for mcux pwm capture pwt driver

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-03-22 12:36:04 +01:00
Daniel DeGrasse 6537a867e3 drivers: pwm: Enable pinctrl for kinetis ftm PWM driver
Enable pinctrl for kinetis ftm PWM driver

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2022-03-22 12:36:04 +01:00
Jay Vasanth 7c65268f3e drivers: pwm: Microchp XEC PWM driver add PINCTRL support
Add build time optional PINCTRL support to common PWM driver
for Microchip XEC MEC15xx and MEC172x families.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-03-21 21:49:50 -04:00
Jay Vasanth 845c1185a2 drivers: pwm: Microchip XEC PWM add MEC172x support
Add support for MEC172x series to Microchip XEC PWM driver.
Standardize device tree properties for both SoC families.
Standardize device structure usage.

Signed-off-by: Jay Vasanth <jay.vasanth@microchip.com>
2022-03-21 21:49:50 -04:00
Andrzej Głąbek a5234f3647 soc_nrf_common: Extend and rename the NRF_DT_ENSURE_PINS_ASSIGNED macro
Extend the macro with checks for DT properties related to pin
assignments that are defined but would be ignored, depending on
whether PINCTRL is enabled or not, what presumably indicates
a resulting configuration different from what the user expects.

Add also a possibility to indicate that the pinctrl-1 property
should not be checked because the caller does not support the
sleep state.

Rename the macro so that its name better reflects its function.
Update accordingly all drivers that use it.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-03-18 16:26:21 +01:00
Francois Ramu 5d9cbbc658 drivers: pwm capture with stm32 can have no callback
When configuring the pwm capture,  the callback function might
be reset, this i not an error. However the isr should not call it
and enabling the capture should always provide a callback function.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2022-03-17 16:34:54 -05:00
Andrzej Głąbek 44feb7d527 drivers: pwm_nrfx: Add support for pinctrl
Add support for the new pinctrl API to the nRF PWM driver.
Update code of the driver and the related devicetree binding.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2022-03-15 18:38:01 +01:00
Nazar Kazakov 9713f0d47c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-14 20:22:24 -04:00
Gerard Marull-Paretas 95fb0ded6b kconfig: remove Enable from boolean prompts
According to Kconfig guidelines, boolean prompts must not start with
"Enable...". The following command has been used to automate the changes
in this patch:

sed -i "s/bool \"[Ee]nables\? \(\w\)/bool \"\U\1/g" **/Kconfig*

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-03-09 15:35:54 +01:00
Fabio Baltieri 61ef77a736 pwm: npcx: only reconfigure PWM if necessary
Currently pwm_npcx_pin_set() disables and reconfigures the PWM
controller every time its called, causing the PWM line to pulse even if
only the duty cycle is changed.

Modify the function so that controller is only disabled if any of the
configuration has to be changed, only set the new DCR otherwise.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-02-21 20:54:42 -05:00
Ruibin Chang 5f3bba54e8 ITE drivers/pwm: support tests/drivers/pwm/pwm_api
Add pwm-0 to support tests/drivers/pwm/pwm_api.

Solve tests code runtime error on it8xxx2_evb:
1.If the pwm channel target frequency is < 1, then we will
  return an error code.

2.If the target_freq is <= 324Hz, we will configure that this pwm
  channel need to output in EC power saving mode.
  In test_pwm_cycle() case, the period is 64000, then the
  target_freq is 8000000 / 64000 = 125Hz and <= 324Hz, so we will
  switch the prescaler clock source from 8MHz to 32.768kHz.
  Then the target_freq is 32768 / 64000 = 0.512Hz and < 1Hz,
  this will return an error code. In order to get the same
  target_freq, we always return PWM_FREQ in
  pwm_it8xxx2_get_cycles_per_sec().

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2022-02-21 20:44:41 -05:00
Yuriy Vynnychek 4089ef71e5 drivers: pwm: telink_b91: replace Pinmux by Pinctrl
Updated driver to use new Pinctrl driver.

Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
2022-02-21 19:41:44 -05:00
Wealian Liao 6d6c5e1155 drivers: npcx: Drop DRV_CONFIG/DRV_DATA usage
Stop using DRV_CONFIG/DRV_DATA macros and use dev->data and dev->config
instead.

Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
2022-01-28 10:06:05 +01:00
Wealian Liao 3565f71a72 drivers: npcx: Correct the macro parentheses
This corrects the following:
1. The priority of type cast is lower than member access. So don't need
the redundant parentheses.
2. The macro should be added to the parentheses.

Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
2022-01-28 10:06:05 +01:00
Gerard Marull-Paretas 8398105d82 drivers: fix style issues
Fix issues reported by checkpatch.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas 1de05e6095 drivers: pwm: drop DEV_DATA/DEV_CFG usage
Stop using redundant DEV_DATA/DEV_CFG macros and use dev->data and
dev->config instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-19 18:16:02 +01:00
Gerard Marull-Paretas ddc168fa78 pm: s/PM_DEVICE_(DT_(INST))_REF/PM_DEVICE_(DT_(INST))_GET
In order to align with macros used to obtain a device reference (e.g.
DEVICE_DT_GET), align the PM macros to use "GET" instead of "REF". This
change should have low impact since no official release has gone out yet
with the "REF" macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-18 12:14:06 -05:00
Gerard Marull-Paretas 1e81e7cded drivers: pwm: gd32: enable gd32vf103
Add dependency on SOC_SERIES_GD32VF103. The driver is compatible as is
with this series.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-01-11 11:50:35 +01:00
Gerard Marull-Paretas 0cb9a1b4cb drivers: pwm: gd32: initial version
Initial version of a PWM driver for GigaDevice GD32 SoCs. Only PWM
output is supported for now (no capture support).

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2022-01-07 14:58:27 -06:00
Gerard Marull-Paretas 5dc6ed3ce3 pinctrl: require ; after PINCTRL_DT_(INST_)DEFINE macros
The PINCTRL_DT_(INST_)DEFINE macros already defined the trailing ;,
making its usage inconsistent with other macros such as
DEVICE_DT_DEFINE.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-01 07:39:08 -05:00
Gerard Marull-Paretas bda8878b03 drivers: pwm: stm32: use instance based macros
Replace usage of DT_DRV_INST with instance based macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-17 17:30:06 +01:00
Gerard Marull-Paretas 45a3985170 drivers: pwm: nrf5_sw: use instance based macros
Replace usage of DT_DRV_INST with instance based macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-17 17:30:06 +01:00
Gerard Marull-Paretas 3e9d8da9ec drivers: use DT_INST_PARENT
Replace usages of DT_PARENT(DT_DRV_INST(idx)) with more idiomatic
DT_INST_PARENT(idx).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-16 11:10:01 -06:00
Daniel DeGrasse b0dfda1584 drivers: pwm_mcux: Update MCUX pwm driver to use clock bindings
MCUX PWM driver used hardcoded clock source. update driver to use clock
bindings to determine PWM peripheral clock frequency.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2021-12-03 16:44:12 -06:00
Antonio Tessarolo cc1cd4d65b arm: Nxp imx6sx added PWM support
This commit adds support for IMX6SX PWM.
The PWM module is the same module present on the IMX7D and so dts
bindings has been renamed following the one present on linux.

Signed-off-by: Antonio Tessarolo <anthonytexdev@gmail.com>
2021-11-30 11:54:11 -06:00
Gerard Marull-Paretas 89a4f36fc8 device: remove inclusion of pm/device.h
The device PM subsystem _depends_ on device, not vice-versa. Devices
only hold a reference to struct pm_device now, and initialize this
reference with the value provided in Z_DEVICE_DEFINE. This requirement
can be solved with a forward struct declaration, meaning there is no
need to include device PM headers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-29 11:08:38 +01:00
Erwan Gouriou eff3ad6df7 drivers/pwm: stm32: use new pinctrl API
Use the new pinctrl API to configure pins.
Since STM32F1 series require pinctrl option and required register
address is parent timer address in place of own node register address,
use PINCTRL_DT_INST_CUSTOM_REG_DEFINE in place of usual
PINCTRL_DT_INST_DEFINE for this specific series.

Additionally, remove the automatic selection of PINMUX API.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-11-26 11:36:42 +01:00
Krzysztof Chruscinski 9886bdc0c8 drivers: pwm: pwm_nrf5_sw: Use runtime resources allocation
Use nrfx_gpiote and nrfx_ppi allocators to allocate channels
at runtime instead of fixed, device-tree based allocation which
is harder to maintain.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-11-26 09:31:54 +01:00
Pawel Dunaj 7ba38d8b26 drivers: pwm: Restore default on re-initialization
Device data is cleared on deinitialization. This operation removes
some important information. Let's restore the defaults each time
the device is initialized.

Signed-off-by: Pawel Dunaj <pawel.dunaj@nordicsemi.no>
2021-11-23 17:00:56 +01:00
Tilmann Unte 38e89c90a5 drivers: pwm: stm32: add pwm capture support
Extends STM32 PWM driver to support capturing pulse width, period,
or both.

The approach used is based on the PWM Input sections in reference
manual RM0351 by ST in the chapters on timers.
The LL library by ST is used for all extensions to the driver.

Only the disco_l475_iot1 board was available for testing on hardware,
using tests/drivers/pwm/pwm_loopback.
Since timers are a generic component, it is assumed that other STM32
boards will behave the same

Fixes #39394

Signed-off-by: Tilmann Unte <unte@es-augsburg.de>
2021-11-22 22:24:45 -05:00
Ruibin Chang 3ab081efe9 ITE drivers/pwm: cleanup it8xxx2 pwm driver
1.Putting the PWM_CHANNEL_X, PWM_PRESCALER_CX information
  in the description.
2.Use the common definition EC_FREQ.
3.Use the common macro IT8XXX2_DT_ALT_ITEMS_LIST.
4.Stop using DRV_CONFIG, DRV_REG macro.

Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw>
2021-11-19 10:24:11 -06:00
Gerard Marull-Paretas 88a69674c0 drivers: use new PM macros
Port some drivers to the recently introduced macros to showcase its
usage and be able to do some initial testing (nRF52840).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-19 10:11:32 +01:00
Alexandre Bourdiol 3a60344522 drivers: pwm: stm32: move "st,prescaler" to timers instead of pwm
Prescaler was misplaced in pwm binding, instead of timers binding.
For example, TIM6/TIM7 doesn't have PWM capability,
but have a prescaler.
This change also prepares the introduction of timer based counter
(which requires prescaler at timer level)
For compatibility reason temporarily use pwm prescaler if it exists,
otehrwise use timers prescaler.
And thus avoid to avoid breaking boards out of tree.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-11-16 09:55:30 -06:00
Andrei-Edward Popa 5413661a81 boards: xtensa: add ledc support to the esp32 board
add ledc to board dtsi file,
change compatible and device define in pwm driver,
add yaml for board ledc support,
fix missing include for board in gpio include

Signed-off-by: Andrei-Edward Popa <andrei_edward.popa@upb.ro>
2021-11-07 05:36:42 -05:00
Gerard Marull-Paretas 4baf1e01ff drivers: use common PM action callback naming
The PM callback is no longer referenced as "pm_control" but
"pm_action_cb", so reflect this new naming on the callbacks.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-03 20:27:18 -04:00
Henrik Brix Andersen 351d065f63 drivers: pwm: mcux: ftm: return -EBUSY if PWM capture in progress
Return -EBUSY (not 0) from pwm_pin_enable_capture() if PWM capture is
already in progress.

Fixes: #39817

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-11-01 22:11:04 -04:00
Sylvio Alves b0717d518e drivers: gpio: esp32: use dts and improve code checks
This PR updates GPIO driver to use DTS information
regarding gpio availability.

This also fixes interrupt handling and
also removes kconfig definition for GPIO port.

A few configuration checks were also added to
improve code usage.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2021-10-21 10:53:34 -04:00
Glauber Maroto Ferreira fb1632925e soc: esp32: partial code standardization
Replaces the prefixes of gpio_matrix_in and gpio_matrix_out
to unify those function calls on all supported socs.

Signed-off-by: Glauber Maroto Ferreira <glauber.ferreira@espressif.com>
2021-10-10 14:52:41 -04:00
Andrzej Głąbek 165c14dc60 drivers: pwm_nrfx: Fix handling of zero length periods
When the driver was called to set the period length for a channel
to 0, it set the COUNTERTOP register in the PWM peripheral to 0,
what resulted in an undefined behavior of the peripheral (and lack
of the STOPPED event sometimes).
The PWM API does not precise how should a zero length period be
handled; some drivers return the -EINVAL error in such case, some
do not. This patch fixes the pwm_nrfx driver so that it does not
change the previously used COUNTERTOP register value when the period
length is set to 0, and because the pulse cycles are always limited
by the driver to period cycles (so 0 in this case), in result the
relevant channel is simply deactivated. This allows users to switch
off a channel by requesting the pulse width to be set to 0 without
providing a non-zero period in such call.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2021-10-08 13:06:40 +02:00
Martí Bolívar 831332068b pwm: it8xxx2: use new DT pinctrl accessors
Update to use the new APIs.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2021-08-25 18:09:00 -04:00
Yuriy Vynnychek 84db9cd36a drivers: pwm: introduce new Telink B91 PWM driver
PWM driver basic support for Telink B91 SoC.

Signed-off-by: Yuriy Vynnychek <yura.vynnychek@telink-semi.com>
2021-08-05 16:11:41 +02:00
Gerard Marull-Paretas 7ccc1a41bc pm: use actions for device PM control
Instead of passing target states, use actions for device PM control.
Actions represent better the meaning of the callback argument.
Furthermore, they are more future proof as they can be suitable for
other PM actions that have no direct mapping to a state. If we compare
with Linux, we could have a multi-stage suspend/resume. Such scenario
would not have a good mapping when using target states.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 6d273f49bd pm: fix incorrect usages of PM_DEVICE_STATE_OFF
According to the documentation the OFF state has to be used when the
devices is fully turned off, ie, power removed. Most drivers were using
a sort of fall-through for all non-active states, leading to behaviors
not following the specifications.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 495672ab62 pm: cleanup pm control callback implementations
- Return -ENOTSUP if the requested state is not supported
- Remove redundant "noop style" functions.
- Use switch everywhere to handle requested state (not necessary in all
  drivers, but better take off with consistency in place after current
  changes).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas d41dadc569 pm: rename PM_DEVICE_STATE_SUSPEND to PM_DEVICE_STATE_SUSPENDED
The verb tense for the suspended state was not consistent with other
states. The likely reason: state was being used as a command/action.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 56a35e5682 pm: converge to suspend state for low power modes
The difference between low power and suspend states is a thin blur line
that is is not clear and most drivers have used indistinctly. This patch
converges to the usage of the suspend state for low power, since
contrary to the low power state, it is used by both system and runtime
device PM. The low power state is still kept, but its future is unclear
and needs some discussion.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas c6cce80ac4 pm: remove incorrect usages of force suspend
Some devices are using PM_DEVICE_STATE_FORCE_SUSPEND as a sort of low
power state, something that is not correct. In fact, this state is not
an actual state and will be eventually moved, if found necessary, to an
action or command.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 920f30cc0e pm: simplify state change check logic
The device PM control function will only be called if the requested
state is different from the current one. A significant amount of drivers
were checking for state changes, now unnecessary. This patch removes all
this redundant logic.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 11eef4d8c8 pm: device: remove pointer usage for state
Since the state is no longer modified by the device PM callback, just
use the state value.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 9e7d545bb4 pm: device: remove ctrl_command callback argument
The ctrl_command is not used anymore, so remove it from the callback
signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas da0ff4ae46 pm: device: remove usage of ctrl_command
The callback is now invoked to set the device PM state in all cases, so
the usage of ctrl_command is redundant.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas c2cf1ad203 pm: device: remove usage of local states
The device PM subsystem already holds the device state, so there is no
need to keep duplicates inside the device. The pm_device_state_get has
been refactored to just return the device state. Note that this is still
not safe, but the same applied to the previous implementation. This
problem will be addressed later.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Mahesh Mahadevan 5f636286d3 drivers: pwm: Add PWM support for NXP LPC devices
Add PWM support using the LPC SCTimer module

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2021-07-30 13:08:03 -05:00
Gerard Marull-Paretas 26ad8376bd pm: remove callback from control function
The callback is not used anymore, so just delete it from the pm_control
callback signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Gerard Marull-Paretas 217e610d8f pm: remove redundant callback usage
the device PM callback is not used anymore by the device PM subsystem,
so remove it from all drivers/tests using it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Marcin Niestroj c28d372d33 drivers: pwm: nrf_sw: drop deprecated 'timer-instance' DT prop
This property has been marked as deprecated in 2.5.0 and was replaced by
'generator' property.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2021-07-12 08:20:47 -05:00
Gerard Marull-Paretas cc2f0e9c08 pm: use enum for device PM states
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.

All drivers and tests have been adjusted accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-07 14:13:12 -04:00
Ruibin Chang d0ce9bb877 ITE drivers/pwm: add PWM for it8xxx2
Add pulse width modulator (PWM) for it8xxx2.

Signed-off-by: Ruibin Chang <ruibin.chang@ite.com.tw>
2021-07-01 13:21:06 -04:00
Fabio Baltieri 3af832868c drivers: npcx: convert NPCX drivers clock client to DEVICE_DT_GET
Convert the various device_get_binding() calls used to get the device
clock node to use DEVICE_DT_GET. The latter is processed at link time,
so it should be a bit more efficient.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2021-06-27 23:02:39 -04:00
Radoslaw Koppel 2d2bc55f51 drivers: pwm: pwm_nrfx: Fix driver suspending
This commit clears current settings of the PWM perihperal
that are stored inside device structure.
This makes sure that PWM period and prescaler is configured
as expected after driver was suspended.

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2021-06-23 03:56:30 -05:00
Kumar Gala 7e52ee7fe1 drivers: pwm: Fix compile issues with Atmel SAM PWM driver
The was a missing comma in the DEVICE_DT_INST_DEFINE macro and the
SAME71 HAL tweaks the name of a struct so we have to work around that.

Fixes #36095

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-06-18 11:22:27 +02:00
Erwan Gouriou fcc3177509 drivers/pinmux: stm32: Move stm32 driver from stm32/
Since we removed various series headers, move stm32 driver
under main driver/pinmux folder.
Take this change into account into various drivers.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-06-11 08:04:39 -05:00
Flavio Ceolin 0c607adb63 pm: device: Align state names with system states
Change device pm states to the same pattern used by system power
management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Flavio Ceolin 7eba310220 power: device: void *context -> uint32_t *state
The context parameter used across device power management is
actually the power state. Just use it and avoid a lot of
unnecessary casts.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Gerard Marull-Paretas 56f1a8ce98 pm: rename PM_DEVICE_GET/SET_POWER_STATE to PM_DEVICE_STATE_GET/SET
Adjust name to be consistent with device PM naming conventions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas dbf46b3815 pm: rename device_pm_cb to pm_device_cb
Prefix all device PM functions/data structures with pm.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 2c7b763e47 pm: replace DEVICE_PM_* states with PM_DEVICE_*
Prefix device PM states with PM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Erwan Gouriou 07e5644ac6 drivers/pwm: stm32: Leftovers in clock_control conversion to dts
Fix omissions.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-05-05 16:51:02 -05:00
Gerard Marull-Paretas 3b18fe0af7 drivers: pwm: remove usage of device_pm_control_nop
device_pm_control_nop is now deprecated in favour of NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 16:43:29 -04:00
Erwan Gouriou 2691541ad2 drivers/clock_controller: stm32: Prepare for dts based configuration
To allow transition to device tree based clock configuration on
stm32 targets, rework clock_control driver to use intermediate
STM32_ macros initially defined as the equivalent Kconfig macros
for now.
Propagate the change in all code using these macros.

The reason to introduce these new macros instead of configuring
Kconfig flags using dt kconfigfunctions is that we'll need
to be able to inform users that Kconfig flags are deprecated
once the whole family conversion is done, to encourage
out of tree users to adopt this new configuration scheme.

Note: For now STM32H7 series and code is excluded.
This is the same for some series specific code such as
PLL mul/div for L0/L1 and XTRE prescaler on F1 series.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-04-27 11:53:37 +02:00
Mulin Chao f16f37f86a driver: pwm: npcx: Add output open drain support
NPCX PWM supports output buffet select to push-pull or open-drain. Add
output buffer select option 'drive-open-drain' in devicetree for NPCX
PWM. If set, the PWM output will be configured as open-drain. If not
set, defaults to push-pull.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
2021-04-22 18:03:38 -04:00
Sidhdharth Yadav e2a29bf6a4 drivers: pwm: Adding a flag to allow build for stm32l1 series
Include a flag to allow build for stm32l1 series

Signed-off-by: Sidhdharth Yadav <sidhdharth.yadav@hcl.com>
2021-04-22 11:29:34 +02:00
Sun Amar 252f1b8e0d gecko pwm: add pwm driver for the gecko.
pwm driver + Kconfig and Cmake files for the
efr32 soc family.

Signed-off-by: Sun Amar <sun681@gmail.com>
2021-04-02 18:45:33 -04:00
Flavio Ceolin 9fd4ea91b7 coccinelle: Remove extra semicolon
coccicheck --mode=patch --cocci=semicolon.cocci

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-03-25 11:35:30 -05:00
Kumar Gala 0eead3aab6 drivers: pwm: NXP: Convert clock control to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the clock controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-18 10:47:15 -06:00
Kumar Gala 3a8fffb9c3 device: rv32m1: Convert clock control to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the clock controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-18 09:26:39 -06:00
Gerard Marull-Paretas 0b07077a5c drivers: pwm: stm32: fix expansion-to-defined warning
The definition to check if timers have up to 6 channels was causing
warnings when -Wexpansion-to-defined was enabled.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2021-02-18 07:19:39 -05:00
Kumar Gala b275fec8c4 soc: stm32: convert to use DEVICE_DT_GET for clocks
Convert from device_get_binding to DEVICE_DT_GET.  In doing this we
no longer need the label in the devicetree node so we remove that.

Removed all __ASSERT_NO_MSG(clk) since we'll get a build error if
DEVICE_DT_GET cant be satisfied, and the clock control api's will
handle reporting if the device_is_ready.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-16 17:01:37 -06:00
Keith Short 5ece02d5dd npcx: fix NPCX PWM driver with PWM_POLARITY_INVERTED
Update NPCX PWM driver so PWM can be turned off as the first call when
PWM_POLARITY_INVERTED is used.

Signed-off-by: Keith Short <keithshort@google.com>
2021-02-10 10:51:55 -05:00
Henrik Brix Andersen 8167134f05 drivers: pwm: add driver for the NXP Kinetis Pulse Width Timer (PWT)
Add PWM capture driver for the NXP Kinetis Pulse Width Timer (PWT).

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-01-20 08:05:57 -06:00
Henrik Brix Andersen 1491fb9de1 drivers: pwm: remove dw and pca9685 drivers
Remove DW and PCA9685 PWM controller drivers as they are unmaintained
and broken.

Both drivers lack support for the pwm_get_cycles_per_sec_t API function
which was introduced in commit 56e0b53c6e
in 2016.

Fixes #18607, #18608

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2021-01-19 09:04:52 -05:00
Mahavir Jain 29f87c3a0f boards: esp32: add XIP support and enable bootloader build
Disable RTC WDT enabled (by default) by 2nd stage bootloader in ESP-IDF.
This WDT timer ensures correct hand-over and startup sequence from
bootloader to application.

Enabling bootloader caused system clock initialization to fail
when clock rate is greater then 80MHz. This also fixes
esp32 clock source code.

Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2021-01-13 09:10:46 -05:00
Henrik Brix Andersen 38279ef365 drivers: pwm: mcux_ftm: add PWM capure support
Add PWM capture support to the NXP MCUX FlexTimer driver.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-01-12 19:43:06 +01:00
Henrik Brix Andersen 77b8440fd1 drivers: pwm: add API for capturing pwm pulse width and period
Extend the PWM API with optional API functions for capturing PWM pulse
width and period cycles.

Fixes #26026.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-01-12 19:43:06 +01:00
Daniel Leung cc9b64080a pwm: convert Synopsys DesignWare PWM to use devicetree
This converts the Designware PWM driver to use devicetree
for device information.

Fixes #30869

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2020-12-20 13:32:15 -05:00
Kumar Gala c372f4ef7d drivers: pwm: Convert DEVICE_AND_API_INIT to DEVICE_DEFINE
Convert driver(s) to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 20:00:00 -05:00
Martin Jäger d6648b6124 drivers: pwm: stm32: add support for L0 series
The STM32L0 series MCUs have quite basic timer features only, so we
remove some unavailable configuration options. They were properly
initilized by the LL StructInit functions for other MCUs anyway.

Signed-off-by: Martin Jäger <martin@libre.solar>
2020-12-17 10:25:34 -05:00
Marcin Niestroj bc5a6164c9 drivers: pwm: nrf_sw: support generating PWM based on RTC
So far nRF's TIMER was used for generating PWM signal. Add support for
generating PWM based on RTC, which is sourced by 32KHz low frequency
crystal. This allows to use low frequency PWM with much lower power
consumption, because high frequency clock path can be disabled.

Don't support RTC clock prescaler, because maximum 512s period covers
most use cases. This allows to adjust pulse and period cycles to the
fact that CLEAR task event is generated always one LFCLK cycle after
period COMPARE value is reached.

Also update hal_nordic revision, as it contains updated check for PPI
channels conflict when RTC is used to generate PWM.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-15 15:19:43 +01:00
Marcin Niestroj 0d58960abb drivers: pwm: nrf_sw: convert to timer phandle instead instance number
So far 'timer-instance' DT property was the way to configure TIMER which
was used for generating PWM signal. Replace that by using 'generator'
phandle, so we get prepared for supporting RTC instances as PWM signal
generator.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-15 15:19:43 +01:00
Marcin Niestroj 4f868cd9fa drivers: pwm: nrf_sw: drop broken runtime timer clock scaling
There is some kind of runtime clock scaling implemented when period
cycles exceed 16-bit value. This is broken, because configured PWM has
far higher frequency in that case. Replace that mechanism with simply
veryfying if requested PWM period does not exceed 16-bit value.

Suggested-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-15 15:19:43 +01:00
Marcin Niestroj 94be9b387a drivers: pwm: nrf_sw: use Nordic HAL to configure GPIO
Use Nordic HAL to configure GPIO output. This adds support for P1 GPIOs,
when pin numbers above 31 are used.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-12-14 20:23:43 -05:00
Kumar Gala 4e6d79cd43 drivers: pwm: pwm_mcux_tpm: Fix build failure
Add a missing ',' in DEVICE_DT_INST_DEFINE

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-11 08:32:14 -06:00
Peter Bigot 65a4910f97 drivers: pwm: fix nrfx pwm device definition
Driver does not use the numeric index directly to identify devicetree
instance nodes.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-11 09:02:35 -05:00
Kumar Gala d3790cec95 drivers: pwm: Convert drivers to new DT device macros
Convert pwm drivers to use new DT variants of the DEVICE APIs.
        DEVICE_AND_API_INIT -> DEVICE_DT_DEFINE

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-10 07:25:29 -05:00
Anas Nashif dd931f93a2 power: standarize PM Kconfigs and cleanup
- Remove SYS_ prefix
- shorten POWER_MANAGEMENT to just PM
- DEVICE_POWER_MANAGEMENT -> PM_DEVICE

and use PM_ as the prefix for all PM related Kconfigs

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-09 15:18:29 -05:00
Mulin Chao daa48daf52 soc: replace DT_ with NPCX_DT_ prefix for all macros in soc_dt.h
This CL replaces all DT_ prefix with NPCX_DT_ for all macros used
for providing npcx device information in soc_dt.h It avoided the
ambiguity with the DT_ prefix for system DT macros/defines.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2020-12-09 00:46:57 -05:00
Mulin Chao 507f31472c driver: clock_controller: return values of clock_control apis directly.
return values of clock_control_on()/clock_control_get_rate() directly in
case overwriting error codes.

Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-12-07 12:11:17 -05:00
Mulin Chao 14b98135fd driver: npcx7: fixed typo in Kconfig.npcx files.
Fixed typo in Kconfig.npcx files.

Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
2020-12-07 12:11:17 -05:00
Martin Jäger fc1c284c9c drivers: pwm: stm32: use generic LL headers
Use generic LL headers instead of depending on soc.h.

Signed-off-by: Martin Jäger <martin@libre.solar>
2020-11-30 15:50:03 +01:00
Henrik Brix Andersen c6f1469bf6 drivers: pwm: add driver for the Xilinx AXI Timer
Add PWM controller driver for the Xilinx AXI Timer v2.0 IP.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2020-11-17 19:30:20 -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
Alexandre Bourdiol c47a5d4a36 drivers: pwm: pwm_stm32.c: enable ARR preload
Enable ARR preload so that period or pulse updates are taken
into account synchronously with update event
(at the end of a ongoing period)
And thus avoid undetermined intermediate pulse.

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2020-10-30 15:59:32 +01:00
Mulin Chao d55aa5a71b driver: npcx7: replace platform specific functions with 'npcx_' prefix.
Replace all platform specific functions with 'npcx_' prefix.

Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-10-21 12:49:02 -05:00
Gerard Marull-Paretas de8134a42e drivers: pwm: stm32: fix timer instance access
The parameters of the associated PWM timer were not being picked up
properly, as it was assumed that parent index is the same as the child
index. This is not necessarily true if other timer nodes are active and
not being used for PWM.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-10-20 09:56:26 -05:00
Erwan Gouriou 0b9c584ec1 drivers/pinmux: stm32: Provide unique API to stm32_dt_pinctrl
Set stm32_dt_pinctrl_configure function as the unique entry point
to STM32 DT pinctrl management.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-20 09:09:29 -05:00
Erwan Gouriou f44e931b0c drivers/pinmux: stm32: Get remap functions visible across family
Move pinctrl remap functions out of stm32f1 definition in order
to get it available to all series.
Allows use of more IS_ENABLED macros in calling drivers and make
code more readable.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-20 09:09:29 -05:00
Erwan Gouriou 0143b5e3de drivers/pinctrl: stm32f1: Provide a function which centralize remap
Centralize AFIO remapping into one single function.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-20 09:09:29 -05:00
Erwan Gouriou b74a2162cb soc/arm: stm32: swap argument order in ST_STM32 PINCTRL macros
In order to be in line with other DT_INST macros in zephyr code base,
swap the arguments order in following macro definitions:
*ST_STM32_DT_PINCTRL
*ST_STM32_DT_INST_PINCTRL
Update the users accordingly.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-09 11:52:59 +02:00
Erwan Gouriou 2d3cda7663 soc/arm: stm32: use _INST_ namespace in devicetree pinctrl helpers
Current set of helpers provided for STM32 pinctrl devicetree are
using device instance as input.
In order to prepare for next version that will take node identifier
as input, change existing set of macros using _INST_ namespace.

Additionally rename NODE_ID_FROM_PINCTRL to
ST_STM32_DT_INST_NODE_ID_FROM_PINCTRL.

Finally update existing macros users to this new name scheme.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-10-09 11:52:59 +02:00
Gerard Marull-Paretas af1b9442ca drivers: pwm: stm32: add support for pinmux
Add support for DT based pinmux configurations.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-10-07 12:27:37 -05:00
Gerard Marull-Paretas aa45e0a90c drivers: pwm: stm32: remove data and config helpers
Now that Zephyr names have been made short and nice the need of these
helpers is less justified.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-10-07 12:27:37 -05:00
Mulin Chao dd99fbebe6 drivers: pwm: add pwm driver support in NPCX7 series
In npcx7 series, there're 8 Pulse Width Modulator (PWM) modules and each
one support generating a single 16-bit PWM output. A 16-bit clock
prescaler (PRSCn) and a 16-bit counter (CTRn) determine the cycle time,
the minimal possible pulse width, and the duty-cycle steps.

Beside introducing pwm driver for Nuvoton NPCX series, this CL also
includes:

1. Add PWM device tree declarations.
2. Zephyr PWM api implementation.
3. Add aliases in npcx7m6fb_evb board device tree file for supporting
   samples/basic/blinky_pwm application and pwm test suites

Signed-off-by: Mulin Chao <MLChao@nuvoton.com>
2020-10-06 18:16:02 -05:00
Xavier Chapron 824f423e54 misc: Replace assert include and calls by sys/__assert.h equivalent
Replace all calls to the assert macro that comes from libc by calls to
__ASSERT_NO_MSG(). This is usefull as the former might be different
depending on the libc used and the later can be customized to reduce
flash footprint.

Signed-off-by: Xavier Chapron <xavier.chapron@stimio.fr>
2020-10-02 11:42:40 +02:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka 98d9b01322 device: Apply driver_api/data attributes rename everywhere
Via coccinelle:

@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
-	driver_api
+	api
|
D->
-	driver_data
+	data
)

@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
-	driver_api
+	api
|
net_if_get_device(E)->
-	driver_data
+	data
)

And grep/sed rules for macros:

git grep -rlz 'dev)->driver_data' |
	xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'

git grep -rlz 'dev->driver_data' |
	xargs -0 sed -i 's/dev->driver_data/dev->data/g'

git grep -rlz 'device->driver_data' |
	xargs -0 sed -i 's/device->driver_data/device->data/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Tomasz Bursztyka af6140cc0d device: Apply config_info rename everywhere
Via coccinelle:

@r_device_config@
struct device *D;
@@

D->
-	config_info
+	config

And 2 grep/sed rules for macros:

git grep -rlz 'dev)->config_info' |
	xargs -0 sed -i 's/dev)->config_info/dev)->config/g'

git grep -rlz 'dev->config_info' |
	xargs -0 sed -i 's/dev->config_info/dev->config/g'

Fixes #27397

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Gerard Marull-Paretas 2ece951c1b drivers: pwm: stm32: fix polarity setting
PWM polarity was not being set correctly because flags were not checked
correctly.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-07-07 15:09:03 +02:00
Michael Hope e362f10d4c drivers: pwm: add a SAM0 TCC based PWM driver
This runs the Timer/Counter for Control in 'normal' PWM mode.  The
number of channels and counter width depends on the device and is
imported from DeviceTree.

Signed-off-by: Michael Hope <mlhx@google.com>
2020-07-01 08:10:59 -05:00
Anas Nashif ee985d81aa shell: enable modules by default if shell is enabled
If shell is enabled then enable all sub-shells if their dependencies are
satisfied. This was done for some modules and subsystems but was not
consistent.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-06-24 21:37:12 -04:00
Gerard Marull-Paretas 76f0d72e5d drivers: pwm: stm32: add support for polarity
Add support for the polarity flag in the STM32 PWM driver.

STM32 boards using PWM have been updated accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-06-19 15:18:50 +02: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
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Henrik Brix Andersen 784c4728b5 drivers: pwm: mcux_ftm: allow configuring the clock prescaler
Allow configuring the clock prescaler divider for the NXP Kinetis
FlexTimer. Setting the prescaler to a lower value allows for much
higher resolution/accuracy for the generated PWM waveforms.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-05-20 19:03:14 +02:00
Martí Bolívar 6e8775ff84 devicetree: remove DT_HAS_NODE_STATUS_OKAY
Several reviewers agreed that DT_HAS_NODE_STATUS_OKAY(...) was an
undesirable API for the following reasons:

- it's inconsistent with the rest of the DT_NODE_HAS_FOO names
- DT_NODE_HAS_FOO_BAR_BAZ(node) was agreed upon as a shorthand
  for macros which are equivalent to
  DT_NODE_HAS_FOO(node) && DT_NODE_HAS_BAR(node) &&
- DT_NODE_HAS_BAZ(node), and DT_HAS_NODE_STATUS_OKAY is an odd duck
- DT_NODE_HAS_STATUS(..., okay) was viewed as more readable anyway
- it is seen as a somewhat aesthetically challenged name

Replace all users with DT_NODE_HAS_STATUS(..., okay), which is
semantically equivalent.

This is mostly done with sed, but a few remaining cases were done by
hand, along with whitespace, docs, and comment changes. These special
cases include the Nordic SOC static assert files.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-13 18:24:42 +02:00
Peter Bigot 4f16b419e8 device: avoid casting away const from config_info pointer
The driver-specific config_info structure referenced from the device
structure is marked const.  Some drivers fail to preserve that
qualifier when casting the pointer to the driver-specific structure,
violating MISRA 11.8.

Changes produced by scripts/coccinelle/const_config_info.cocci.

Some changes proposed by the script are not included because they
reveal mutation of state through the const pointer, though the
code works as long as the driver-specific object is defined without
the const qualifier.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-05-13 18:21:52 +02:00
Martí Bolívar 7e0eed9235 devicetree: allow access to all nodes
Usually, we want to operate only on "available" device
nodes ("available" means "status is okay and a matching binding is
found"), but that's not true in all cases.

Sometimes we want to operate on special nodes without matching
bindings, such as those describing memory.

To handle the distinction, change various additional devicetree APIs
making it clear that they operate only on available device nodes,
adjusting gen_defines and devicetree.h implementation details
accordingly:

- emit macros for all existing nodes in gen_defines.py, regardless
  of status or matching binding
- rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY
- rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY
- rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY
- rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY
- rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS
- resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS
- remove DT_COMPAT_ON_BUS as a public API
- use the new default_prop_types edtlib parameter

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-08 19:37:18 -05:00
Tomasz Bursztyka 97326c0445 device: Fix structure attributes access
Since struct devconfig was merged earlier into struct device, let's fix
accessing config_info, name, ... attributes everywhere via:

grep -rlZ 'dev->config->' | xargs -0 sed -i 's/dev->config->/dev->/g'

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +02:00
Kumar Gala 0a7d4e2135 devicetree: Change DT_FOREACH_IMPL_ to not insert semicolon
Remove semicolon between instance invocations of DT_FOREACH_IMPL_ and
thus DT_INST_FOREACH.  This provides more flexibility to the user.  This
requires we fixup in tree users to add semicolon where needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-07 20:03:56 -05:00
Martí Bolívar 87e1743ae0 devicetree: replace DT_HAS_DRV_INST with DT_INST_FOREACH
Make drivers multi-instance wherever possible using DT_INST_FOREACH.
This allows removing DT_HAS_DRV_INST in favor of making drivers just
do the right thing regardless of how many instances there are.

There are a few exceptions:

- SoC drivers which use CMake input files (like i2c_dw.c) or otherwise
  would require more time to convert than I have at the moment. For the
  sake of expediency, just inline the DT_HAS_DRV_INST expansion for
  now in these cases.

- SoC drivers which are explicitly single-instance (like the nRF SAADC
  driver). Again for the sake of expediency, drop a BUILD_ASSERT in
  those cases to make sure the assumption that all supported SoCs have
  at most one available instance is valid, failing fast otherwise.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-05-06 17:35:08 -05:00
Alex Porosanu f4c36b7beb drivers: pwm: add driver for NXP Kinetis TPM module
The TPM (Timer/PWM Module) is a 2- to 8-channel timer which supports
input capture, output compare, and the generation of PWM signals to
control electric motor and power management applications.

This patch adds the driver and the binding necessary for instantiating
the driver. The work is based on the RV32M1 driver for TPM done by
Henrik Brix Andersen. A later patch will enable this driver to be used
for the KW41Z SoC, if PWM support is requested.

Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
2020-05-06 11:33:37 -05:00
Kumar Gala fdd85d5ad7 dts: Rename DT_HAS_NODE macro to DT_HAS_NODE_STATUS_OKAY
Rename DT_HAS_NODE to DT_HAS_NODE_STATUS_OKAY so the semantics are
clear.  As going forward DT_HAS_NODE will report if a NODE exists
regardless of its status.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-06 05:25:41 -05:00
Kumar Gala 81e44f005e drivers: pwm: Remove per instance Kconfig symbols
There are now no users of the per instance Kconfig symbols so we can now
remove them.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-05 12:46:57 -05: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
Kumar Gala b04b399d63 drivers: pwm: nrfx: Convert to use DTS NODELABEL for instance detection
Move to using NODELABEL references to enable driver instances for
PWM0..3.  This will allow us to remove per-instance PWM Kconfig symbols.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-05-05 08:40:19 -05:00
Henrik Brix Andersen 9ceb29ac56 dts: introduce shared binding for the NXP FlexTimer
Do not assume in the SoC level device trees that NXP Kinetis FlexTimer
nodes will always be configured as PWM. Instead, configure FlexTimer
nodes for PWM at the board level for NXP Kinetis boards.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-04-30 08:28:48 -05:00
Martí Bolívar be84c4ebbf drivers: pwm: nordic: move to new DT API
DT API conversion only.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
2020-04-24 17:00:13 +02:00
Kumar Gala 476e90a6a5 drivers: pwm: pwm_mcux: Convert driver to new DT_INST macros
Convert driver to use DT_INST macros and remove related board per
instance Kconfig symbol usage.  We also remove dts_fixup.h defines that
are no longer needed.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-20 11:08:46 -05:00
Kumar Gala f72bfda53c drivers: pwm: pwm_nrf5_sw: Convert to new DT_INST macros
Convert older DT_INST_ macro use the new include/devicetree.h
DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-15 11:17:32 -05:00
Kumar Gala 5dd1a79230 drivers: pwm: rv32m1_tpm: Use DT_INST_FOREACH
Convert driver to use DT_INST_FOREACH(TPM_DEVICE)

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-10 14:38:04 -05:00
Kumar Gala 9c229e9169 drivers: pwm: pwm_imx: Convert driver to new DT_INST macros
Convert driver to use DT_INST macros and remove related board per
instance Kconfig symbol usage.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-04-04 09:34:00 -05:00
Gerard Marull-Paretas 4194360cb5 drivers: pwm: stm32: add support for H7 series
Enable PWM support for H7 series.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2020-04-04 15:00:11 +02:00
Kumar Gala 36049b1657 drivers: Convert to use DT_INST_FOREACH
Convert drivers that have the following pattern:

   #if DT_INST_NODE_HAS_PROP(0, label)
   INIT_MACRO(0)
   #endif

   ...

   #if DT_INST_NODE_HAS_PROP(n, label)
   INIT_MACRO(n)
   #endif

to use DT_INST_FOREACH(INIT_MACRO) instead.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-31 19:29:22 -05:00
Kumar Gala 88469b7010 drivers: litex: Convert litex drivers to new DT_INST macros
Convert older DT_INST_ macro use in litex drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-30 12:49:43 -05:00
Kumar Gala 63ccb98eee drivers: openisa: Convert openisa drivers to new DT_INST macros
Convert older DT_INST_ macro use in openisa drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-27 05:28:37 -05:00
Kumar Gala 7a81cd9747 drivers: microchip: Convert microchip drivers to new DT_INST macros
Convert older DT_INST_ macro use in microchip drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 16:31:52 -05:00
Kumar Gala 3af49c5b55 drivers: atmel sam: Convert atmel sam drivers to new DT_INST macros
Convert older DT_INST_ macro use in atmel sam drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 16:31:31 -05:00
Kumar Gala 020a899ec3 drivers: sifive: Convert sifive drivers to new DT_INST macros
Convert older DT_INST_ macro use in sifive drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 16:06:09 -05:00
Kumar Gala 989484b4bf drivers: stm32: Convert STM32 drivers to new DT_INST macros
Convert older DT_INST_ macro use in STM32 drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 12:22:12 -05:00
Kumar Gala 8ea8925ebe drivers: esp32: Convert esp32 drivers to new DT_INST macros
Convert older DT_INST_ macro use in esp32 drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 08:49:11 -05:00
Kumar Gala 4b9fe8a24e drivers: mcux: Convert MCUX drivers to new DT_INST macros
Convert older DT_INST_ macro use in MCUX drivers to the new
include/devicetree.h DT_INST macro APIs.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 03:40:09 -05:00
Marek Pieta 75e36ed352 drivers: pwm_nrfx: Wait until PWM is stopped before restarting it
Change adds waiting until PWM is stopped before restarting it. Without
the change, calling the pwm_nrfx_pin_set function multiple times in
quick succession could cause a race condition causing the PWM to
remain stopped in case it should be restarted.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2020-03-19 12:29:51 +01:00
Erwan Gouriou ac516aa888 drivers: pwm: pmw_stm32: convert to DT_INST defines
Convert driver to use DT_INST_ defines.
Removed DT_FLASH_DEV fixup macros.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2020-03-17 11:03:10 -06:00
Henrik Brix Andersen 2703d4cd20 drivers: pwm: mcux_ftm: configure pwm in ticks, not frequency/percent
Configure the PWM period and pulse width in timer ticks instead of
calculating the frequency and duty cycle for use in the higher level
MCUX API. This improves the resolution of the PWM output signal
considerably.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-03-16 17:34:54 -05:00
Andrzej Głąbek 668d401293 modules: hal: nordic: Define NRFX_ASSERT as __ASSERT_NO_MSG
Update hal_nordic's revision, so that NRFX_ASSERT uses __ASSERT_NO_MSG
directly, not through the assert macro that comes from from libc,
as the definition of the latter might be different when some specific
libc version is used, and this could generate troubles.

Replace also uses of assert() with __ASSERT_NO_MSG() in nrfx driver
shims that use this macro without including the corresponding header
file (i.e. that implicitly rely on assert.h being included from
nrfx_glue.h, which is no longer the case).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-03-10 17:21:27 +01:00
Ulf Magnusson 378d6b137a kconfig: Replace non-defconfig single-symbol 'if's with 'depends on'
Same deal as in commit eddd98f811 ("kconfig: Replace some single-symbol
'if's with 'depends on'"), for the remaining cases outside defconfig
files. See that commit for an explanation.

Will do the defconfigs separately in case there are any complaints
there.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-12 10:32:34 -06:00
Mohamed ElShahawi fef3ebaa69 drivers: gpio_esp32: update to use new GPIO API
- Updates gpio driver and device tree files to the new GPIO Config flags
- Implements the new port_* APIs
- Update I2C and PWM Drivers to use new GPIO config
- Add esp32.overlay to gpio_basic_api test
- refactor convert_int_type, regs struct
- remove config_polarity
- add kConfig notes

Tests:
- samples/basic/blinky
- samples/basic/button
- tests/drivers/gpio/gpio_basic_api
- tests/drivers/gpio/gpio_api_1pin

Board:
- esp32 DevKitC V4

Note about interrupts:
The ESP32 requires specifying a CPU interrupt to be used for GPIO
interrupt signals.  CPU interrupts can be either level or edge (or
special) triggered, but not both.
Please check gpio/Kconfig.esp32 for more info.

Signed-off-by: Mohamed ElShahawi <ExtremeGTX@hotmail.com>
2020-02-05 12:00:36 +01:00
Peter Bigot 12e30f16c9 treewide: use full path to pwm.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Peter Bigot 0b0d2e640b treewide: use full path to clock_control/stm32_clock_control.h header
The build infrastructure should not be adding the drivers subdirectory
to the include path.  Fix the legacy uses that depended on that
addition.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-01-26 17:52:12 +01:00
Henrik Brix Andersen 3e7ca8f2ad drivers: pwm: add driver for the RV32M1 Timer/PWM module
Add driver for the OpenISA Timer/PWM (TPM) module present in the
RV32M1 SoC.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2020-01-13 09:12:34 -06:00
Robert Winkler 56db098a55 drivers: pwm: Add driver for LiteX PWM peripherial
PWM driver for LiteX SoC builder was created.
Because LiteX supports only one channel for each PWM device,
an appropriate restriction was made.

Signed-off-by: Robert Winkler <rwinkler@internships.antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
2020-01-08 11:04:36 +01:00
Henrik Brix Andersen e2346cf6a2 drivers: pwm: mcux_ftm: add support for inverted polarity pwm signals
Add support for specifying the PWM signal polarity through flags to
the NXP Kinetis FlexTimer (FTM) PWM driver.

Prior to this change the FTM PWM driver always produced inverted
polarity (active-low) PWM signals.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-07 18:13:18 +01:00
Henrik Brix Andersen eafb9b17b6 drivers: pwm: shell: add PWM flags support
Add support for specifying flags in the PWM shell commands.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-07 18:13:18 +01:00
Henrik Brix Andersen db611e6781 drivers: pwm: add support for inverted PWM signals
Add support for requesting an inverted PWM pulse (active-low) when
setting up the period and pulse width of a PWM pin. This is useful
when driving external, active-low circuitry (e.g. an LED) with a PWM
signal.

All in-tree PWM drivers is updated to match the new API signature, but
no driver support for inverted PWM signals is added yet.

All in-tree PWM consumers are updated to pass a flags value of 0
(0 meaning default, which is normal PWM polarity).

Fixes #21384.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-07 18:13:18 +01:00
Henrik Brix Andersen 9efc58961c drivers: pwm: mcux_ftm: use DT_INST_* defines instead of dts fixups
Convert the NXP MCUX FTM driver to use the DT_INST_* defines instead
of a mix of CONFIG_PWM_* and dts fixups. This simplifies adding new
device tree properties to the ftm nodes.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-06 10:03:20 -06:00
Henrik Brix Andersen 7694ebb694 drivers: pwm: mcux_ftm: only emit warning on period change from zero
Only emit a warning about changing PWM period for all channels of a
given FTM instance when changing the period from zero to
non-zero. This silences the useless warning issued at first FTM PWM
channel configuration.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2020-01-06 10:03:20 -06:00
Jose Alberto Meza 7c25431655 drivers: pwm: xec: Use unique log module identifier for PWM
Use unique log module identifier for PWM to avoid link error.

Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
2019-12-12 11:47:50 -08:00
Ulf Magnusson 984bfae831 global: Remove leading/trailing blank lines in files
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.

Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.

Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-12-11 19:17:27 +01:00
Tomasz Bursztyka c9e0876421 drivers/pwm: Fix abs() usage in xec driver
Seems to be fine to temporarly cast to int there as frequencies are in
Mhz and not Ghz.

Fixes #20497
Coverity CID: 205638

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2019-12-03 13:34:19 -05:00
Daniel Leung ceb2303dd0 pwm: pwm_mchp_xec: fix potential out of bound access
Fix an issue discovered by Coverity where there is a potential
out of bound access on the divisor arrays.

Fixes #20495
Fixes #20496

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2019-11-27 13:00:13 -05:00
Francois Ramu 458a8a0a41 driver: pwm: Error handling issues in pwm_stm32_get_cycles_per_sec
This patch tests the return code when calling clock_control_get_rate
and completes the issue  #20503 seen on watchdog
[Coverity CID :205655]

Fixes #20503

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2019-11-18 09:18:13 -06:00
Andrzej Głąbek b1d5eed262 drivers: nrfx: Update implementations after switching to nrfx 2.0.0
Update calls to nrfx HAL functions to reflect API changes introduced in
nrfx 2.0.0. All these functions are now called with the first parameter
pointing to the structure of registers of the relevant peripheral.
Also a few functions got renamed:
- nrf_gpiote_int_is_enabled to nrf_gpiote_int_enable_check
- nrf_gpiote_event_is_set to nrf_gpiote_event_check
- nrf_rng_event_get to nrf_rng_event_check
- nrf_rng_int_get to nrf_rng_int_enable_check
- nrf_rtc_event_pending to nrf_rtc_event_check
- nrf_rtc_int_is_enabled to nrf_rtc_int_enable_check
- nrf_timer_cc_read to nrf_timer_cc_get
- nrf_timer_cc_write to nrf_timer_cc_set

Default configuration values were removed from nrfx_config files,
so the drivers pwm_nrfx and spi_nrfx_spis no longer can use those.

Function nrfx_pwm_init() now takes one more parameter - context pointer
that is passed to the event handler, not used in the pwm_nrfx driver.

HALs for UART and UARTE now allow configuration of the parity type
and the number of stop bits, for SoCs that provide the corresponding
registers.

Signed-off-by: Karol Lasończyk <karol.lasonczyk@nordicsemi.no>
Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2019-11-08 14:54:12 +01:00