aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/pwm (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-04-03pwm: pca9685: Fix PWM/GPIO inter-operationSven Van Asbroeck1-37/+48
This driver allows pwms to be requested as gpios via gpiolib. Obviously, it should not be allowed to request a GPIO when its corresponding PWM is already requested (and vice versa). So it requires some exclusion code. Given that the PWMm and GPIO cores are not synchronized with respect to each other, this exclusion code will also require proper synchronization. Such a mechanism was in place, but was inadvertently removed by Uwe's clean-up in commit e926b12c611c ("pwm: Clear chip_data in pwm_put()"). Upon revisiting the synchronization mechanism, we found that theoretically, it could allow two threads to successfully request conflicting PWMs/GPIOs. Replace with a bitmap which tracks PWMs in-use, plus a mutex. As long as PWM and GPIO's respective request/free functions modify the in-use bitmap while holding the mutex, proper synchronization will be guaranteed. Reported-by: YueHaibing <yuehaibing@huawei.com> Fixes: e926b12c611c ("pwm: Clear chip_data in pwm_put()") Cc: Mika Westerberg <mika.westerberg@linux.intel.com> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Cc: YueHaibing <yuehaibing@huawei.com> Link: https://lkml.org/lkml/2019/5/31/963 Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> [cg: Tested on an i.MX6Q board with two NXP PCA9685 chips] Tested-by: Clemens Gruber <clemens.gruber@pqgruber.com> Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com> # cg's rebase Link: https://lore.kernel.org/lkml/20200330160238.GD2817345@ulmo/ Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-04-03pwm: Make pwm_apply_state_debug() staticJason Yan1-2/+2
Fix the following gcc warning: drivers/pwm/core.c:467:6: warning: symbol 'pwm_apply_state_debug' was not declared. Should it be static? Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Jason Yan <yanaijie@huawei.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-04-03pwm: meson: Remove redundant assignment to variable fin_freqColin Ian King1-1/+1
The variable fin_freq is being initialized with a value that is never read and it is being updated later with a new value. The initialization is redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King <colin.king@canonical.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: jz4740: Allow selection of PWM channels 0 and 1Paul Cercueil1-5/+14
The TCU channels 0 and 1 were previously reserved for system tasks, and thus unavailable for PWM. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Tested-by: Mathieu Malaterre <malat@debian.org> Tested-by: Artur Rojek <contact@artur-rojek.eu> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: jz4740: Obtain regmap from parent nodePaul Cercueil2-24/+44
The TCU registers are shared between a handful of drivers, accessing them through the same regmap. While this driver is devicetree-compatible, it is never (as of now) probed from devicetree, so this change does not introduce a ABI problem with current devicetree files. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Tested-by: Mathieu Malaterre <malat@debian.org> Tested-by: Artur Rojek <contact@artur-rojek.eu> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: jz4740: Improve algorithm of clock calculationPaul Cercueil1-15/+29
The previous algorithm hardcoded details about how the TCU clocks work. The new algorithm will use clk_round_rate to find the perfect clock rate for the PWM channel. This code relies on the fact that clk_round_rate() will always round down, which is not a valid assumption given by the clk API, but only happens to be true with the clk drivers used for Ingenic SoCs. Right now, there is no alternative as the clk API does not have a round-down function (and won't have one for a while), but if it ever comes to light, a round-down function should be used instead. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Tested-by: Mathieu Malaterre <malat@debian.org> Tested-by: Artur Rojek <contact@artur-rojek.eu> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: jz4740: Use clocks from TCU driverPaul Cercueil2-14/+41
The ingenic-timer "TCU" driver provides us with clocks, that can be (un)gated, reparented or reclocked from devicetree, instead of having these settings hardcoded in this driver. The new code now uses a clk pointer per PWM (instead of a clk per pwm-chip before). So the pointer is stored in per-pwm data now. The calls to arch-specific timer code is replaced with standard clock API calls to start and stop each channel's clock. While this driver is devicetree-compatible, it is never (as of now) probed from devicetree, so this change does not introduce a ABI problem with current devicetree files. Signed-off-by: Paul Cercueil <paul@crapouillou.net> Tested-by: Mathieu Malaterre <malat@debian.org> Tested-by: Artur Rojek <contact@artur-rojek.eu> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: sun4i: Remove redundant needs_delayPascal Roeleven1-11/+2
'needs_delay' does now always evaluate to true, so remove all occurrences. Signed-off-by: Pascal Roeleven <dev@pascalroeleven.nl> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: omap-dmtimer: Implement .apply callbackLokesh Vutla1-51/+129
Implement .apply callback and drop the legacy callbacks(enable, disable, config, set_polarity). In .apply() check for the current hardware status before changing the PWM configuration. Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Tested-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: omap-dmtimer: Do not disable PWM before changing period/duty_cycleLokesh Vutla1-14/+7
Only the Timer control register(TCLR) cannot be updated when the timer is running. Registers like Counter register (TCRR), loader register (TLDR) and match register (TMAR) can be updated while the counter is running. Since TCLR is not updated in pwm_omap_dmtimer_config(), do not stop the timer for period/duty_cycle update. Tested-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: omap-dmtimer: Fix PWM enabling sequenceLokesh Vutla1-5/+5
To configure DM timer in PWM mode the following needs to be set in OMAP_TIMER_CTRL_REG using set_pwm callback: - Set toggle mode on PORTIMERPWM output pin - Set trigger on overflow and match on PORTIMERPWM output pin. - Set auto reload This is a one time configuration and needs to be set before the start of the DM timer. But the current driver tries to set the same configuration for every period/duty cycle update, which is not needed. So move the PWM setup before enabling timer and do not update it in pwm_omap_dmtimer_config(). Tested-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: omap-dmtimer: Update description for PWM OMAP DM timerLokesh Vutla1-1/+9
Update the description with a brief about how PWM is generated using OMAP DM timer and add limitations for the PWM generations. Also add a link to the reference manual. Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: omap-dmtimer: Drop unused header fileLokesh Vutla1-11/+9
pwm_omap_dmtimer.h is used only: - to typedef struct omap_dm_timer to pwm_omap_dmtimer - for macro PWM_OMAP_DMTIMER_TRIGGER_OVERFLOW_AND_COMPARE Rest of the file is pretty mush unsed. So reuse omap_dm_timer and OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE in pwm-omap-dmtimer.c and delete the header file. Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: renesas-tpu: Drop confusing registered messageGeert Uytterhoeven1-2/+0
During device probe, the message TPU PWM -1 registered is printed. While the "-1" looks suspicious, it is perfectly normal for a device instantiated from DT. Remove the message, as there are no non-DT users left, and other drivers don't print such messages either. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: renesas-tpu: Fix late Runtime PM enablementGeert Uytterhoeven1-5/+4
Runtime PM should be enabled before calling pwmchip_add(), as PWM users can appear immediately after the PWM chip has been added. Likewise, Runtime PM should always be disabled after the removal of the PWM chip, even if the latter failed. Fixes: 99b82abb0a35b073 ("pwm: Add Renesas TPU PWM driver") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: rcar: Fix late Runtime PM enablementGeert Uytterhoeven1-3/+7
Runtime PM should be enabled before calling pwmchip_add(), as PWM users can appear immediately after the PWM chip has been added. Likewise, Runtime PM should be disabled after the removal of the PWM chip. Fixes: ed6c1476bf7f16d5 ("pwm: Add support for R-Car PWM Timer") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: meson: Fix confusing indentationKrzysztof Kozlowski1-1/+1
Fix indentation of return block. Smatch warning: drivers/pwm/pwm-meson.c:139 meson_pwm_request() warn: inconsistent indenting Reported-by: kbuild test robot <lkp@intel.com> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Acked-by: Neil Armstrong <narmstrong@baylibre.com> Fixes: 211ed630753d ("pwm: Add support for Meson PWM Controller") Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: pca9685: Use gpio core provided macro GPIO_LINE_DIRECTION_OUTRishi Gupta1-1/+1
GPIO core recently added macro to uniformly specify direction of a GPIO line, so use it. Signed-off-by: Rishi Gupta <gupt21@gmail.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: pca9685: Replace CONFIG_PM with __maybe_unusedRishi Gupta1-4/+2
The __maybe_unused attribute is preferred over CONFIG_PM to prevent potential build time issues. This commit replaces CONFIG_PM with this attribute. Signed-off-by: Rishi Gupta <gupt21@gmail.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: tegra: Add support for Tegra194Sandipan Patra1-0/+6
Tegra194 has multiple PWM controllers with each having only one output. Also the maxmimum frequency is higher than earlier SoCs. Add support for Tegra194 and specify the number of PWM outputs and maximum supported frequency using device tree match data. Signed-off-by: Sandipan Patra <spatra@nvidia.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Acked-by: Rob Herring <robh@kernel.org> Acked-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: Enable compile testing for some of driversKrzysztof Kozlowski1-22/+25
Some of the PWM drivers can be compile tested to increase build coverage. The Meson PWM driver requires COMMON_CLK dependency. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Acked-by: Florian Fainelli <f.fainelli@gmail.com> # For Broadcoam Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> # For Meson Acked-by: Claudiu Beznea <claudiu.beznea@microchip.com> # For Atmel Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: pca9685: Remove unused duty_cycle struct elementMatthias Schiffer1-4/+0
duty_cycle was only set, never read. Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: mxs: Remove unused include of of_address.hAnson Huang1-1/+0
There is nothing in use from of_address.h, remove it. Signed-off-by: Anson Huang <Anson.Huang@nxp.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: imx27: Remove unused include of of_device.hAnson Huang1-1/+0
There is nothing in use from of_device.h, remove it. Signed-off-by: Anson Huang <Anson.Huang@nxp.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: imx-tpm: Remove unused includesAnson Huang1-2/+0
There is nothing in use from log2.h/of_address.h, remove them. Signed-off-by: Anson Huang <Anson.Huang@nxp.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: Implement some checks for lowlevel driversUwe Kleine-König2-7/+137
There are some expectations which the callbacks provided by lowlevel drivers should fulfill. Implement checks that help driver authors to get these semantics right. As these have some overhead the checks can be disabled using a Kconfig setting. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: imx27: Ensure clocks being on iff the PWM is onUwe Kleine-König1-2/+12
Up to now the .probe() function didn't enable clocks and relied on the core to call the .get_state() callback to have the clock running. The latter enabled the needed clocks and kept them running if the PWM wass enabled. This only works correctly if the .get_state() callback is called exactly once and this single call happens before unused clocks are disabled by the clk core. The former wasn't true for a short period while commit 01ccf903edd6 ("pwm: Let pwm_get_state() return the last implemented state") applied and not reverted yet and might become wrong in the future. The latter isn't true any more since commit cfc4c189bc70 ("pwm: Read initial hardware state at request time") which results in a running PWM being stopped at boot time if for example the consumer lives in a kernel module that is only loaded after the clk core disabled unused clocks. So ensure .probe() is left with the clocks on if the PWM is running and .get_state() disables everything it enabled. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: imx27: Don't disable clocks at device remove timeUwe Kleine-König1-2/+0
The .remove() callback is not supposed to modify hardware state. This is in the responsibility of the PWM consumer. After the PWM was disabled the clocks are off (apart from a bug that is fixed in the next patch), so unbinding the driver either stops the PWM (which it should not) or disables already disabled clocks yielding warnings from the clk core. So just drop the call to disable the clocks. (Which BTW was also in the wrong order because the call makes the PWM unfunctional and so should have come only after pwmchip_remove()). Fixes: 9f4c8f9607c3 ("pwm: imx: Add ipg clock operation") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: imx27: Simplify helper function to enable and disable clocksUwe Kleine-König1-10/+7
pwm_imx27_clk_prepare_enable() took a pointer to a struct pwm_chip just to convert it to a struct pwm_imx27_chip pointer while all callers already have the latter. Ditto for pwm_imx27_clk_disable_unprepare(). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: imx27: Fix clock handling in pwm_imx27_apply()Uwe Kleine-König1-1/+1
pwm_imx27_apply() enables the clocks if the previous PWM state was disabled. Given that the clocks are supposed to be left on iff the PWM is running, the decision to disable the clocks at the end of the function must not depend on the previous state. Without this fix the enable count of the two affected clocks increases by one whenever ->apply() changes from one disabled state to another. Fixes: bd88d319abe9 ("pwm: imx27: Unconditionally write state to hardware") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-30pwm: bcm2835: Dynamically allocate baseFlorian Fainelli1-0/+1
The newer 2711 and 7211 chips have two PWM controllers and failure to dynamically allocate the PWM base would prevent the second PWM controller instance being probed for succeeding with an -EEXIST error from alloc_pwms(). Fixes: e5a06dc5ac1f ("pwm: Add BCM2835 PWM driver") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-03-16clocksource/drivers/timer-ti-dm: Enable autoreload in set_pwmLokesh Vutla1-3/+5
dm timer ops set_load() api allows to configure the load value and to set the auto reload feature. But auto reload feature is independent of load value and should be part of configuring pwm. This way pwm can be disabled by disabling auto reload feature using set_pwm() so that the current pwm cycle will be completed. Else pwm disabling causes the cycle to be stopped abruptly. Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20200305082715.15861-7-lokeshvutla@ti.com
2020-01-20pwm: Remove set but not set variable 'pwm'yu kuai1-4/+0
Fixes gcc '-Wunused-but-set-variable' warning: drivers/pwm/pwm-pca9685.c: In function ‘pca9685_pwm_gpio_free’: drivers/pwm/pwm-pca9685.c:162:21: warning: variable ‘pwm’ set but not used [-Wunused-but-set-variable] It is never used, and so can be removed. In that case, hold and release the lock 'pca->lock' can be removed since nothing will be done between them. Fixes: e926b12c611c ("pwm: Clear chip_data in pwm_put()") Signed-off-by: yu kuai <yukuai3@huawei.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: sun4i: Initialize variables before useThierry Reding1-2/+2
GCC can't always determine that the duty, period and prescaler values are initialized when returning from sun4i_pwm_calculate(), so help out a little by initializing them to 0. Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: stm32: Remove automatic output enableFabrice Gasnier1-3/+1
Don't use AOE (automatic output enable) by default. In case of break events, PWM is automatically re-enabled on next PWM cycle otherwise. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: sun4i: Narrow scope of local variableUwe Kleine-König1-3/+5
The variable pval is only used in a single block in the function sun4i_pwm_calculate(). So declare it in a more local scope to simplify the function for humans and compilers. While at it also simplify assignment to pval. While the diffstat for this patch is negative for this patch I still thing the advantage of having a narrower scope is beneficial. In my compiler / .config setup (gcc 8.2.1, arm/imx_v6_v7_defconfig + COMPILE_TEST + PWM_SUN4I) this change doesn't result in any binary changes. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: bcm2835: Allow building for ARCH_BRCMSTBFlorian Fainelli1-1/+1
BCM7211 is supported using ARCH_BRCMSTB and uses this PWM controller driver, make it possible to build it. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: imx27: Eliminate error message for defer probeAnson Huang1-3/+7
For defer probe error, no need to output error message which will cause confusion. Signed-off-by: Anson Huang <Anson.Huang@nxp.com> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: sun4i: Fix inconsistent IS_ERR and PTR_ERRGustavo A. R. Silva1-3/+3
Fix inconsistent IS_ERR and PTR_ERR in sun4i_pwm_probe(). The proper pointers to be passed as arguments are pwm->clk and pwm->bus_clk. This bug was detected with the help of Coccinelle. Fixes: b8d74644f34a ("pwm: sun4i: Prefer "mod" clock to unnamed") Fixes: 5b090b430d75 ("pwm: sun4i: Add an optional probe for bus clock") Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: sun4i: Move pwm_calculate() out of spin_lock()Clément Péron1-4/+3
pwm_calculate() calls clk_get_rate() while holding a spin_lock(). This create an issue as clk_get_rate() may sleep. Move pwm_calculate() out of this spin_lock(). Fixes: c32c5c50d4fe ("pwm: sun4i: Switch to atomic PWM") Reported-by: Alexander Finger <alex.mobigo@gmail.com> Sugested-by: Vasily Khoruzhick <anarsoul@gmail.com> Tested-by: Alexander Finger <alex.mobigo@gmail.com> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Clément Péron <peron.clem@gmail.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: omap-dmtimer: Allow compiling with COMPILE_TESTUwe Kleine-König1-1/+2
The dependency on OMAP_DM_TIMER is only a runtime dependency. Also OMAP_DM_TIMER cannot be enabled without ARCH_OMAP being enabled. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: omap-dmtimer: put_device() after of_find_device_by_node()Uwe Kleine-König1-6/+15
This was found by coccicheck: drivers/pwm/pwm-omap-dmtimer.c:304:2-8: ERROR: missing put_device; call of_find_device_by_node on line 255, but without a corresponding object release within this function. Reported-by: Markus Elfring <elfring@users.sourceforge.net> Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: omap-dmtimer: Simplify error handlingUwe Kleine-König1-9/+19
Instead of doing error handling in the middle of ->probe(), move error handling and freeing the reference to timer to the end. This fixes a resource leak as dm_timer wasn't freed when allocating *omap failed. Implementation note: The put: label was never reached without a goto and ret being unequal to 0, so the removed return statement is fine. Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: omap-dmtimer: Remove PWM chip in .remove before making it unfunctionalUwe Kleine-König1-1/+6
In the old code (e.g.) mutex_destroy() was called before pwmchip_remove(). Between these two calls it is possible that a PWM callback is used which tries to grab the mutex. Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers") Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: Implement tracing for .get_state() and .apply_state()Uwe Kleine-König1-1/+8
This allows to log all calls to the driver's lowlevel functions which simplifies debugging in some cases. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: rcar: Document inability to set duty_cycle = 0Uwe Kleine-König1-0/+3
When .apply() is called with state->duty_cycle = 0 the duty_ns parameter to rcar_pwm_set_counter() is 0 which results in ph being 0 and rcar_pwm_set_counter() returning -EINVAL. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-20pwm: rcar: Drop useless call to pwm_get_state()Uwe Kleine-König1-2/+0
pwm_get_state has no side effects and the resulting pwm_state is unused. So drop the call to pwm_get_state() and the local variable from rcar_pwm_apply(). The call was introduced in commit 7f68ce8287d3 ("pwm: rcar: Add support "atomic" API") and already then was useless. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-08pwm: Fix minor Kconfig whitespace issuesKrzysztof Kozlowski1-2/+2
Remove double whitespace after "config" keyword. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-08pwm: atmel: Implement .get_state()Uwe Kleine-König1-0/+40
This function reads back the configured parameters from the hardware. As .apply() rounds down (mostly) I'm rounding up in .get_state() to achieve that applying a state just read from hardware is a no-op. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Acked-by: Claudiu Beznea <claudiu.beznea@microchip.com> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2020-01-08pwm: atmel: Use register accessors for channelsUwe Kleine-König1-2/+2
This makes it a bit easier when instrumenting register access to only have to add code in one place. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>