summaryrefslogtreecommitdiffstats
path: root/drivers/pwm/pwm-axi-pwmgen.c
Commit message (Collapse)AuthorAgeFilesLines
* pwm: axi-pwmgen: Let .round_waveform_tohw() signal when request was rounded upUwe Kleine-König2025-04-071-3/+7
| | | | | | | | | | | | The .round_waveform_tohw() is supposed to return 1 if the requested waveform cannot be implemented by rounding down all parameters. Also adapt the corresponding comment to better describe why the implemented procedure is right. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Tested-by: Trevor Gamblin <tgamblin@baylibre.com> Link: https://lore.kernel.org/r/ba451573f0218d76645f068cec78bd97802cf010.1743844730.git.u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
* pwm: axi-pwmgen: Enable FORCE_ALIGN by defaultDavid Lechner2024-10-251-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | Enable the FORCE_ALIGN flag by default in the AXI PWMGEN driver. This flag makes the behavior of the PWM output consistent with the description at the top of the driver file. * Limitations: * - The writes to registers for period and duty are shadowed until * LOAD_CONFIG is written to AXI_PWMGEN_REG_RSTN, at which point * they take effect. * - Writing LOAD_CONFIG also has the effect of re-synchronizing all * enabled channels, which could cause glitching on other channels. It * is therefore expected that channels are assigned harmonic periods * and all have a single user coordinating this. Without this flag, the PWM output does not change until the period of all PWM output channels has run out, which makes the PWM impossible to use in some cases because it takes too long to change the output. Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20241009-pwm-axi-pwmgen-enable-force_align-v1-2-5d6ad8cbf5b4@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
* pwm: axi-pwmgen: Rename 0x10 registerDavid Lechner2024-10-251-6/+6
| | | | | | | | | | | | | | | | | | | Rename the 0x10 register from REG_CONFIG to REG_RSTN. Also rename the associated bit macros accordingly. While touching this, move the bit macros close to the register address macro for better organization. According to [1], the name of the 0x10 register is REG_RSTN, and there is a different register named REG_CONFIG (0x18). So we should not be using REG_CONFIG for the 0x10 register to avoid confusion. [1]: http://analogdevicesinc.github.io/hdl/library/axi_pwm_gen/index.html Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20241009-pwm-axi-pwmgen-enable-force_align-v1-1-5d6ad8cbf5b4@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
* Merge tag 'pwm/duty_offset-for-6.13-rc1' of ↵Uwe Kleine-König2024-10-251-43/+105
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux pwm: Support for duty_offset Support a new abstraction for pwm configuration that allows to specify the time between start of period and the raising edge of the signal ("duty offset"). This is used in a patch series by Trevor Gamblin for triggering an ADC conversion and afterwards read out the result. See https://lore.kernel.org/linux-iio/20240909-ad7625_r1-v5-0-60a397768b25@baylibre.com/ for more details.
| * pwm: axi-pwmgen: Implementation of the waveform callbacksUwe Kleine-König2024-09-281-43/+105
| | | | | | | | | | | | | | | | | | | | Convert the axi-pwmgen driver to use the new callbacks for hardware programming. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Tested-by: Trevor Gamblin <tgamblin@baylibre.com> Link: https://lore.kernel.org/r/922277f07b1d1fb9c9cd915b1ec3fdeec888a916.1726819463.git.u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
* | pwm: axi-pwmgen: Create a dedicated function for getting driver data from a chipUwe Kleine-König2024-10-251-2/+7
|/ | | | | | | | | | | | | | | | Compared to direct calls to pwmchip_get_drvdata() a dedicated function has two upsides: A better name and the right type. So the code becomes easier to read and the new function is harder to use wrongly. Another side effect (which is the secret motivation for this patch, but shhh) is that the driver becomes a bit easier to backport to kernel versions that don't have devm_pwmchip_alloc() yet. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com> Link: https://lore.kernel.org/r/20240923125418.16558-2-u.kleine-koenig@baylibre.com [ukleinek: added an * to the new function's prototype to make the compiler happy] Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
* pwm: axi-pwmgen: use shared macro for version regDavid Lechner2024-09-161-2/+1
| | | | | | | | | | The linux/fpga/adi-axi-common.h header already defines a macro for the version register offset. Use this macro in the axi-pwmgen driver instead of defining it again. Signed-off-by: David Lechner <dlechner@baylibre.com> Link: https://lore.kernel.org/r/20240816-pwm-axi-pwmgen-use-shared-macro-v1-1-994153ebc3a7@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
* pwm: axi-pwmgen: add .max_register to regmapTrevor Gamblin2024-07-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This was missed in the basic driver and is useful for debug, so add it. Example regmap output before the patch: |root@zed-tg:~# cat /sys/kernel/debug/regmap/44a60000.pwm/registers |0: 00020100 And with it: |root@zed-tg:~# cat /sys/kernel/debug/regmap/44a60000.pwm/registers |00: 00020100 |04: 00000000 |08: 00000000 |0c: 601a3471 |10: 00000000 |14: 00000002 |18: 00000001 |1c: 00000000 |... Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Link: https://lore.kernel.org/r/20240711125743.3956935-1-tgamblin@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
* pwm: axi-pwmgen: Make use of regmap_clear_bits()Uwe Kleine-König2024-07-101-1/+1
| | | | | | | | | | | Instead of using regmap_update_bits() and passing val=0, better use regmap_clear_bits(). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Acked-by: Trevor Gamblin <tgamblin@baylibre.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20240606164047.534741-6-u.kleine-koenig@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
* pwm: Add driver for AXI PWM generatorDrew Fustini2024-07-101-0/+241
Add support for the Analog Devices AXI PWM Generator. This device is an FPGA-implemented peripheral used as PWM signal generator and can be interfaced with AXI4. The register map of this peripheral makes it possible to configure the period and duty cycle of the output signal. Link: https://analogdevicesinc.github.io/hdl/library/axi_pwm_gen/index.html Co-developed-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Co-developed-by: David Lechner <dlechner@baylibre.com> Signed-off-by: David Lechner <dlechner@baylibre.com> Signed-off-by: Drew Fustini <dfustini@baylibre.com> Acked-by: Nuno Sa <nuno.sa@analog.com> Co-developed-by: Trevor Gamblin <tgamblin@baylibre.com> Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com> Link: https://lore.kernel.org/r/20240605203507.1934434-3-tgamblin@baylibre.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>