Commit graph

1564 commits

Author SHA1 Message Date
Uwe Kleine-König 5d0237a7b0 pwm: jz4740: Make use of devm_pwmchip_alloc() function
This prepares the pwm-jz4740 driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Acked-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/14a081c097b4e7c7f346ca6557ece8d16ad5749d.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:10 +01:00
Uwe Kleine-König 4eeb33229c pwm: jz4740: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/86b8a362f1e50c5b95c43e056d03ee5ca66d1641.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:10 +01:00
Uwe Kleine-König cebf107de5 pwm: jz4740: Change prototype of a helper to prepare further changes
This prepares the driver for further changes that will make it harder to
determine the pwm_chip from a given jz4740_pwm_chip. To just not have to
do that, rework jz4740_pwm_can_use_chn() to take a pwm_chip.

Link: https://lore.kernel.org/r/83b826f0bf58b93f26d3bc30b1a957f84eedf41a.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:10 +01:00
Uwe Kleine-König 1b6691680b pwm: iqs620a: Make use of devm_pwmchip_alloc() function
This prepares the pwm-iqs620a driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/85cb0e73baadd76ede364abc4b57ee72000880e5.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:10 +01:00
Uwe Kleine-König 07b61160e4 pwm: iqs620a: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct
pwm_chip chip from struct iqs620_pwm_private. The only two functions
that make use of struct iqs620_pwm_private::chip (apart from the probe
function that is handled later when converting to pwmchip_alloc()) only
use the chip's device pointer. Introduce such a pointer in driver data
and use that instead.

Link: https://lore.kernel.org/r/e6b1636c0d26d8bcb02a66b2963e2cc394014d76.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:10 +01:00
Uwe Kleine-König 8a18b97332 pwm: iqs620a: Create a wrapper for converting a pwm_chip to driver data
There is no semantic change. The new function just implements what was
open-coded twice in the driver before.

Link: https://lore.kernel.org/r/cc7ab547b4c4b79456b548aa72205bcf4476db8c.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:10 +01:00
Uwe Kleine-König a1d81abc03 pwm: intel-lgm: Make use of devm_pwmchip_alloc() function
This prepares the pwm-intel-lgm driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/3b2be81b046fe2213736ad37153131d5f4c859f5.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:10 +01:00
Uwe Kleine-König abf6569d64 pwm: imx-tpm: Make use of devm_pwmchip_alloc() function
This prepares the pwm-tmp driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/5de5d53295fa445d58a79f83421dd3406166c3c6.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:10 +01:00
Uwe Kleine-König dcef3929e0 pwm: imx27: Make use of devm_pwmchip_alloc() function
This prepares the pwm-imx27 driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Also convert the to_pwm_imx27_chip() helper macro to a static inline to
get some type safety.

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://lore.kernel.org/r/3da748c80e9bbe29e7c119190dbc4bd67d159f22.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:09 +01:00
Uwe Kleine-König 175f53a78c pwm: imx27: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/a8e3e3b3ea0684c9b289999c6f09eedbc2520f54.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:09 +01:00
Uwe Kleine-König 5911fc37c7 pwm: imx1: Make use of devm_pwmchip_alloc() function
This prepares the pwm-imx1 driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Also convert the to_pwm_imx1_chip() helper macro to a static inline to
get some type safety.

Link: https://lore.kernel.org/r/c6995e0d281255a7514edf9f25a561302dcaf65f.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:09 +01:00
Uwe Kleine-König 12ca0c331a pwm: img: Make use of devm_pwmchip_alloc() function
This prepares the pwm-img driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/d99e00af2ff09cd3587d9a7c51dc8e0e13f85208.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:09 +01:00
Uwe Kleine-König b097d28e33 pwm: img: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct
pwm_chip chip from struct img_pwm_chip. Use the pwm_chip as driver data
instead of the img_pwm_chip to get access to the pwm_chip in
img_pwm_remove() and the PM callbacks without using imgchip->chip.

Link: https://lore.kernel.org/r/2ddf76d127f69eca7d9faa6475091e432e890ac9.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:09 +01:00
Uwe Kleine-König 2231f6fe83 pwm: img: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/bbea7e6e4c5412c6b0773faa9f165b6311cd53b6.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:09 +01:00
Uwe Kleine-König 9bd3e889d2 pwm: img: Drop write-only variable from driver private data
struct img_pwm_chip::dev is only assigned to, but the member variable is
never used. So drop it.

Link: https://lore.kernel.org/r/7b7de753caa453c7fe591228c9a45d0baf8b5878.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:09 +01:00
Uwe Kleine-König 19248d867b pwm: hibvt: Make use of devm_pwmchip_alloc() function
This prepares the pwm-hibvt driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/7b12504b4128969bdc783bf2bff1ecc63b7c7bd4.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:09 +01:00
Uwe Kleine-König c8cf591113 pwm: hibvt: Consistently name driver data hi_pwm_chip
The driver uses two different names for variables of type
hibvt_pwm_chip:

	$ git grep 'struct hibvt_pwm_chip \*' v6.8-rc1 drivers/pwm/pwm-hibvt.c
	v6.8-rc1:drivers/pwm/pwm-hibvt.c:static inline struct hibvt_pwm_chip *to_hibvt_pwm_chip(struct pwm_chip *chip)
	v6.8-rc1:drivers/pwm/pwm-hibvt.c:       struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip);
	v6.8-rc1:drivers/pwm/pwm-hibvt.c:       struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip);
	v6.8-rc1:drivers/pwm/pwm-hibvt.c:       struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip);
	v6.8-rc1:drivers/pwm/pwm-hibvt.c:       struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip);
	v6.8-rc1:drivers/pwm/pwm-hibvt.c:       struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip);
	v6.8-rc1:drivers/pwm/pwm-hibvt.c:       struct hibvt_pwm_chip *hi_pwm_chip = to_hibvt_pwm_chip(chip);
	v6.8-rc1:drivers/pwm/pwm-hibvt.c:       struct hibvt_pwm_chip *pwm_chip;
	v6.8-rc1:drivers/pwm/pwm-hibvt.c:       struct hibvt_pwm_chip *pwm_chip;

Most functions use "hi_pwm_chip" as name. Make use of this in the
remaining two functions (that used "pwm_chip" before, which isn't
optimal as this is a type name, too).

Link: https://lore.kernel.org/r/66ff5a9b00889ff0c576afc783424478fbbb9853.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:09 +01:00
Uwe Kleine-König 2e8d68c02e pwm: fsl-ftm: Make use of devm_pwmchip_alloc() function
This prepares the pwm-fsl-ftm driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/b3c75dea5b2944402b14944fdf71a5db0e26cbd7.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:09 +01:00
Uwe Kleine-König 097779f157 pwm: fsl-ftm: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct
pwm_chip chip from struct fsl_pwm_chip. Use the pwm_chip as driver data
instead of the fsl_pwm_chip to get access to the pwm_chip in
fsl_pwm_suspend() and fsl_pwm_resume() without using fpc->chip.

Link: https://lore.kernel.org/r/2cf27e2929505c05f84501d6fce96f23eba03fc3.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:08 +01:00
Uwe Kleine-König 74836319c2 pwm: fsl-ftm: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/131f976a8f876a88e2a940f5acf6aa1d81833b89.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:08 +01:00
Uwe Kleine-König e80c1aa6ae pwm: fsl-ftm: Change prototype of a helper to prepare further changes
This prepares the driver for further changes that will make it harder to
determine the pwm_chip from a given fsl_pwm_chip. To just not have to
do that, rework fsl_pwm_apply_config() to take a pwm_chip.

Link: https://lore.kernel.org/r/5f0e88afe25d6a218032891a34f963980814b760.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:08 +01:00
Uwe Kleine-König 3f681ff7ba pwm: ep93xx: Make use of devm_pwmchip_alloc() function
This prepares the pwm-ep93xx driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/9420eeca1eb18fada4a15c897f60696b7b22b532.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:08 +01:00
Uwe Kleine-König ecb4ec5ab8 pwm: ep93xx: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/3bf56f20bc7f749e5a353cdcfad11dd1ba573381.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:08 +01:00
Uwe Kleine-König 4839f5a7c4 pwm: dwc-core: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/5240ba82ac227e3723678041bd69b9c7a9e3db43.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:08 +01:00
Uwe Kleine-König 1647e5065b pwm: dwc: Make use of devm_pwmchip_alloc() function
This prepares the pwm-dwc driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Also convert the to_dwc_pwm() helper macro to a static inline to get
some type safety.

Link: https://lore.kernel.org/r/64e64a9a8644600d51b234ad9bcae951b5748998.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:04:08 +01:00
Uwe Kleine-König aaa3cc29a7 pwm: dwc: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct
pwm_chip chip from struct dwc_pwm. Use the pwm_chip as driver
data and return value of dwc_pwm_alloc() instead of the dwc_pwm to get
access to the pwm_chip in dwc_pwm_probe() and dwc_pwm_suspend() without
using dwc->chip.

Thanks to Raag Jadav for providing a hunk of this patch that Uwe missed
during creation of this patch.

Link: https://lore.kernel.org/r/008ce5ab84b8e3baa3e81ab6d36dbb0e4be5c319.1707900770.git.u.kleine-koenig@pengutronix.de
Link: https://lore.kernel.org/r/20240219033835.11369-2-raag.jadav@intel.com
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-19 11:02:57 +01:00
Uwe Kleine-König 452be9421e pwm: cros-ec: Make use of devm_pwmchip_alloc() function
This prepares the pwm-cros-ec driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.
The probe function had to be changed a bit because the number of PWMs
must be determined before allocation of the pwm_chip and its private
data now.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/b0afe9e25340f0a274ff3806687cf37a6cc31557.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:21 +01:00
Uwe Kleine-König 19a568a8d3 pwm: cros-ec: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/486c40609bd9e339d7e5576e2501f63111b59b8b.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:21 +01:00
Uwe Kleine-König 7256c2e79b pwm: cros-ec: Change prototype of helpers to prepare further changes
pwm_chip allocation and registration is about to change. For that the
number of PWM devices must be known earlier in cros_ec_pwm_probe(). So
make cros_ec_pwm_get_duty() and cros_ec_num_pwms() independent of
struct cros_ec_pwm_device which is only available later.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/c0cfc75c1cba0f735555e0138387143ec101feb3.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:21 +01:00
Uwe Kleine-König b1a80d5053 pwm: crc: Make use of devm_pwmchip_alloc() function
This prepares the pwm-crc driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/bbe4896eabc240c678c66fabb6329f4e6cd04eda.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:21 +01:00
Uwe Kleine-König 5b86d1112b pwm: crc: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/a41b62365295be9debd4a9aaa80ca87fca35b320.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:21 +01:00
Uwe Kleine-König 4709f38308 pwm: crc: Simplify code to determine the pwmchip's parent device
There is already a pointer to the pwmchip, make use of it directly
instead of using the struct crystalcove_pwm *crc_pwm just obtained from
it. This also has the advantage of not using struct
crystalcove_pwm::chip any more which will be dropped soon.

Link: https://lore.kernel.org/r/66d55649e13526bbd95d7bfd1cacfa0beb9efd43.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:21 +01:00
Uwe Kleine-König 5412170f10 pwm: clps711x: Make use of devm_pwmchip_alloc() function
This prepares the pwm-clps711x driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/334e633bb8e4c26dc59883b068466387769b65f9.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:21 +01:00
Uwe Kleine-König 8e87e3dcb2 pwm: clk: Make use of devm_pwmchip_alloc() function
This prepares the pwm-clk driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Also convert the to_pwm_clk_chip() helper macro to a static inline to
get some type safety.

Link: https://lore.kernel.org/r/c02ccc955fe7a0aec7ce0ccaf5cd2bd902ae687f.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König fc6549a936 pwm: clk: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct
pwm_chip chip from struct pwm_clk_chip. Use the pwm_chip as driver data
instead of the pwm_clk_chip to get access to the pwm_chip in
pwm_clk_remove() without using pcchip->chip.

Link: https://lore.kernel.org/r/cfbb7c571489ac3d9ca13835b3bd038aaca69638.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König f3d1efd083 pwm: brcmstb: Make use of devm_pwmchip_alloc() function
This prepares the pwm-brcmstb driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/adf9cb04f5d84ae604e97d4dc0708ff3677d72d7.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König bf756bfd24 pwm: berlin: Make use of devm_pwmchip_alloc() function
This prepares the pwm-berlin driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/52866502c96a80d1c30be003dc1f5a89a4d230cc.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König 5874eaf869 pwm: berlin: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct
pwm_chip chip from struct berlin_pwm_chip. Use the pwm_chip as driver
data instead of the berlin_pwm_chip to get access to the pwm_chip in
berlin_pwm_suspend() and berlin_pwm_resume() without using bpc->chip.

Link: https://lore.kernel.org/r/d2a0c5b664ef1bfd4719c645c069717d63fb4e65.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König e5c368b821 pwm: bcm-kona: Make use of devm_pwmchip_alloc() function
This prepares the pwm-bcm-kona driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/b50fe94dc72af602e7061839b24f48af6e005ef8.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König 2089ecaa49 pwm: bcm-kona: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/f0086ed37f30c4d25bf226e722f5ae52a73974d9.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König d502386c2b pwm: bcm-iproc: Make use of devm_pwmchip_alloc() function
This prepares the pwm-bcm-iproc driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/cdc6136b94f685c85a615e9e5ccbd7ebb2f91cfc.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König 19c09ed094 pwm: bcm2835: Make use of devm_pwmchip_alloc() function
This prepares the pwm-bcm2835 driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/441489772bdfbb2cd206fd534b36c63e8c50843a.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König af184748c6 pwm: atmel-tcb: Make use of devm_pwmchip_alloc() function
This prepares the pwm-atmel-tcb driver to further changes of the pwm
core outlined in the commit introducing devm_pwmchip_alloc(). There is
no intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/c845e6c9d27c8a4037755b2ae702b0039947a3c1.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König dfab73eb28 pwm: atmel-tcb: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct
pwm_chip chip from struct atmel_tcb_pwm_chip. Use the pwm_chip as driver
data instead of the atmel_tcb_pwm_chip to get access to the pwm_chip in
the .suspend() and .resume() callbacks and atmel_tcb_pwm_remove()
without using tcbpwm->chip.

Link: https://lore.kernel.org/r/6a90083e9d1ab1c34422161593d6d7a669143217.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:20 +01:00
Uwe Kleine-König 44fe6578b8 pwm: atmel-tcb: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/463d43cab01f97f3c4247c63cc08e76aa15684c4.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:19 +01:00
Uwe Kleine-König 93dcf8e00e pwm: atmel-hlcdc: Make use of devm_pwmchip_alloc() function
This prepares the pwm-atmel-hlcdc driver to further changes of the pwm
core outlined in the commit introducing devm_pwmchip_alloc(). There is
no intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/4724c6a0f052160ac80ba5a3065c9470778b7457.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:19 +01:00
Uwe Kleine-König 0ba76822eb pwm: atmel-hlcdc: Prepare removing pwm_chip from driver data
This prepares the driver for further changes that will drop struct
pwm_chip chip from struct atmel_hlcdc_pwm. Use the pwm_chip as driver
data instead of the atmel_hlcdc_pwm to get access to the pwm_chip in
the .suspend() and .resume() callbacks and atmel_hlcdc_pwm_remove()
without using atmel->chip.

Link: https://lore.kernel.org/r/0e97342f15540c7330d405eaaf3e68baa8e1e488.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:19 +01:00
Uwe Kleine-König 8de8ccaca9 pwm: atmel: Make use of devm_pwmchip_alloc() function
This prepares the pwm-atmel driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/f2a83af5660de461b4dcaf76929e9813bddfeff1.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:19 +01:00
Uwe Kleine-König f9e4d438e1 pwm: atmel: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/f8ca10033204111e4eb2e7a4dad0bd1f7586c735.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:19 +01:00
Uwe Kleine-König cc2b5bc614 pwm: atmel: Change prototype of a helper to prepare further changes
This prepares the driver for further changes that will make it harder to
determine the pwm_chip from a given atmel_pwm_chip. To just not have to
do that, rework atmel_pwm_enable_clk_if_on() to take a pwm_chip.

Link: https://lore.kernel.org/r/c9a92f77760e401debfe0c9bfc086222f31fb3c4.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:19 +01:00
Uwe Kleine-König 5dd820cbfc pwm: apple: Make use of devm_pwmchip_alloc() function
This prepares the pwm-apple driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/34cf20a82ca07bb4ec0578b193daa5caed37825e.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:19 +01:00
Uwe Kleine-König 6357c2cd05 pwm: ab8500: Make use of devm_pwmchip_alloc() function
This prepares the pwm-ab8500 driver to further changes of the pwm core
outlined in the commit introducing devm_pwmchip_alloc(). There is no
intended semantical change and the driver should behave as before.

Link: https://lore.kernel.org/r/9c952baafe7e53c482adf23215138724b61e376b.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:19 +01:00
Uwe Kleine-König 96af28dc44 pwm: ab8500: Introduce a local pwm_chip variable in .probe()
This simplifies converting the driver to pwmchip_alloc() as there is only
a single code line left that makes use of struct ab8500_pwm_chip::chip.

Link: https://lore.kernel.org/r/7fae4833b97728abc8bd400663fdd331c86a761b.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:19 +01:00
Uwe Kleine-König ddabe9093c pwm: ab8500: Make use of pwmchip_parent() accessor
struct pwm_chip::dev is about to change. To not have to touch this
driver in the same commit as struct pwm_chip::dev, use the accessor
function provided for exactly this purpose.

Link: https://lore.kernel.org/r/24028d8d0add621a0c054235e6281a05a83d8fb4.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:19 +01:00
Uwe Kleine-König 024913dbf9 pwm: Provide pwmchip_alloc() function and a devm variant of it
This function allocates a struct pwm_chip and driver data. Compared to
the status quo the split into pwm_chip and driver data is new, otherwise
it doesn't change anything relevant (yet).

The intention is that after all drivers are switched to use this
allocation function, its possible to add a struct device to struct
pwm_chip to properly track the latter's lifetime without touching all
drivers again. Proper lifetime tracking is a necessary precondition to
introduce character device support for PWMs (that implements atomic
setting and doesn't suffer from the sysfs overhead of the /sys/class/pwm
userspace support).

The new function pwmchip_priv() (obviously?) only works for chips
allocated with pwmchip_alloc().

Link: https://lore.kernel.org/r/9577d6053a5a52536057dc8654ff567181c2da82.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:59:15 +01:00
Uwe Kleine-König 4e59267c7a pwm: Provide an inline function to get the parent device of a given chip
Currently a pwm_chip stores in its struct device *dev member a pointer
to the parent device. Preparing a change that embeds a full struct
device in struct pwm_chip, this accessor function should be used in all
drivers directly accessing chip->dev now. This way struct pwm_chip and
this new function can be changed without having to touch all drivers in
the same change set.

Make use of this function in the framework's core sources.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/cc30090d2f9762bed9854a55612144bccc910781.1707900770.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:37:29 +01:00
Rafał Miłecki eb58bf4afd pwm: mediatek: add support for MT7988
MT7988 uses new registers layout just like MT7981 but it supports 8 PWM
interfaces.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20240214140454.6438-2-zajec5@gmail.com
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:32:14 +01:00
Raag Jadav 3ee35fd12b pwm: dwc: access driver_data using dev_get_drvdata()
Now that we're setting driver_data using dev_set_drvdata(), we can use
dev_get_drvdata() for accessing it.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240212130247.9985-6-raag.jadav@intel.com
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:29:20 +01:00
Uwe Kleine-König 1706175c68 pwm: imx27: Don't use pwm consumer API
Lowlevel driver callbacks are not supposed to use the consumer API
functions. Currently this works, but with the upcoming locking changes
this maybe results in dead locks. So directly access pwm->state.

Link: https://lore.kernel.org/r/20240126101624.2056801-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:28:02 +01:00
Uwe Kleine-König f8b403f544 pwm: atmel: Don't use pwm consumer API
Lowlevel driver callbacks are not supposed to use the consumer API
functions. Currently this works, but with the upcoming locking changes
this probably results in dead locks.

Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Link: https://lore.kernel.org/r/20240129085627.2386470-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:28:02 +01:00
Uwe Kleine-König c6c3f7e73d pwm: atmel-hlcdc: Don't use pwm consumer API
Lowlevel driver callbacks are not supposed to use the consumer API
functions. Currently this works, but with the upcoming locking changes
this probably results in dead locks.

Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Link: https://lore.kernel.org/r/6e34607828b290cd64ca9f82df40872853069f07.1706269232.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:28:02 +01:00
Uwe Kleine-König 65a63bf94a pwm: bcm2835: Drop write-only member of driver private data
Since commit fcc7607293 ("pwm: bcm2835: Allow PWM driver to be used in
atomic context") struct bcm2835_pwm::dev is only assigned a value, but
it's never used. So the dev member can just be dropped.

Link: https://lore.kernel.org/r/20240129081029.2355612-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:28:02 +01:00
Uwe Kleine-König 62928315ad pwm: Reorder symbols in core.c
This moves the functions called by pwm consumers above the functions
called by pwm providers. When character device support is added later
this is hooked into the chip registration functions. As the needed
callbacks are a kind of consumer and make use of the consumer functions,
having this order is more natural and prevents having to add
declarations for static functions.

Also move the global variables for pwm tables to the respective
functions to have them properly grouped.

Link: https://lore.kernel.org/r/eed83de07bdfb69b5ceba0b9aed757ee612dea8f.1706182805.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:28:02 +01:00
Uwe Kleine-König e92ce0e8f9 pwm: mediatek: Update kernel doc for struct pwm_mediatek_of_data
The struct never had a member called clk_freq. This fixes the W=1
warning:

	drivers/pwm/pwm-mediatek.c:60: warning: Excess struct member 'clk_freq' description in 'pwm_mediatek_chip'

Fixes: efecdeb82f ("pwm: mediatek: Allocate the clks array dynamically")
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20240125085649.1571268-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:28:02 +01:00
Uwe Kleine-König 91bb23493f pwm: Drop duplicate check against chip->npwm in of_pwm_xlate_with_flags()
args->args[0] is passed as parameter "index" to pwm_request_from_chip().
The latter function also checks for index >= npwm, so
of_pwm_xlate_with_flags() doesn't need to do that.

Link: https://lore.kernel.org/r/b06e445a6ed62a339add727eccb969a33d678386.1704835845.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:28:02 +01:00
Uwe Kleine-König 0e253d4193 pwm: clps711x: Drop custom .of_xlate() callback
The default of_xlate callback (of_pwm_xlate_with_flags()) does
everything the drivers expects from its .of_xlate() callback. So drop
the custom implementation.

Link: https://lore.kernel.org/r/f58336c298d536107de5cab6a57e19f957ab326c.1704835845.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:28:02 +01:00
Uwe Kleine-König 40ade0c2e7 pwm: Let the of_xlate callbacks accept references without period
With this extension of_pwm_xlate_with_flags() is suitable to replace the
custom xlate function of the pwm-clps711x driver.

While touching these very similar functions align their implementations.

Link: https://lore.kernel.org/r/127622315d07d9d419ae8e6373c7e5be7fab7a62.1704835845.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:28:02 +01:00
Uwe Kleine-König 4e77431cda pwm: Drop useless member .of_pwm_n_cells of struct pwm_chip
Apart from the two of_xlate implementations this member is write-only.
In the of_xlate functions of_pwm_xlate_with_flags() and
of_pwm_single_xlate() it's more sensible to check for args->args_count
because this is what is actually used in the device tree.

Acked-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/53d8c545aa8f79a920358be9e72e382b3981bdc4.1704835845.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:28:01 +01:00
Raag Jadav 7cfce2b80d pwm: dwc: use pm_sleep_ptr() macro
Since we don't have runtime PM handles here, we should be using
pm_sleep_ptr() macro, so that the compiler can discard it in case
CONFIG_PM_SLEEP=n.

Fixes: 30b5b066fa ("pwm: dwc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions")
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240212130247.9985-2-raag.jadav@intel.com
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-15 12:27:50 +01:00
Uwe Kleine-König 5f62383558 pwm: sti: Fix capture for st,pwm-num-chan < st,capture-num-chan
The driver only used the number of pwm channels to set the pwm_chip's
npwm member. The result is that if there are more capture channels than
PWM channels specified in the device tree, only a part of the capture
channel is usable. Fix that by passing the bigger channel count to the
pwm framework. This makes it possible that the .apply() callback is
called with .hwpwm >= pwm_num_devs, catch that case and return an error
code.

Fixes: c97267ae83 ("pwm: sti: Add PWM capture callback")
Link: https://lore.kernel.org/r/20240204212043.2951852-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-07 21:13:59 +01:00
Uwe Kleine-König e25ac87d3f pwm: atmel-hlcdc: Fix clock imbalance related to suspend support
The suspend callback disables the periph clock when the PWM is enabled
and resume reenables this clock if the PWM was disabled before. Judging
from the code comment it's suspend that is wrong here. Fix accordingly.

Fixes: f9bb9da7c0 ("pwm: atmel-hlcdc: Implement the suspend/resume hooks")
Reviewed-by: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Link: https://lore.kernel.org/r/b51ea92b0a45eff3dc83b08adefd43d930df996c.1706269232.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-02-04 13:53:57 +01:00
Uwe Kleine-König 9320fc509b pwm: jz4740: Don't use dev_err_probe() in .request()
dev_err_probe() is only supposed to be used in probe functions. While it
probably doesn't hurt, both the EPROBE_DEFER handling and calling
device_set_deferred_probe_reason() are conceptually wrong in the request
callback. So replace the call by dev_err() and a separate return
statement.

This effectively reverts commit c0bfe9606e ("pwm: jz4740: Simplify
with dev_err_probe()").

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20240106141302.1253365-2-u.kleine-koenig@pengutronix.de
Fixes: c0bfe9606e ("pwm: jz4740: Simplify with dev_err_probe()")
Cc: stable@vger.kernel.org
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-01-12 18:25:05 +01:00
Uwe Kleine-König a297d07b9a pwm: Fix out-of-bounds access in of_pwm_single_xlate()
With args->args_count == 2 args->args[2] is not defined. Actually the
flags are contained in args->args[1].

Fixes: 3ab7b6ac5d ("pwm: Introduce single-PWM of_xlate function")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/243908750d306e018a3d4bf2eb745d53ab50f663.1704835845.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-01-12 18:24:55 +01:00
Sean Young 678164a5f0 pwm: bcm2835: Remove duplicate call to clk_rate_exclusive_put()
devm_add_action_or_reset() already calls the action in the error case.

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Closes: https://lore.kernel.org/linux-pwm/fuku3b5ur6y4k4refd3vmeoenzjo6mwe3b3gtel34rhhhtvnsa@w4uktgbqsc3w/
Fixes: fcc7607293 ("pwm: bcm2835: Allow PWM driver to be used in atomic context")
Signed-off-by: Sean Young <sean@mess.org>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Link: https://lore.kernel.org/r/20231222131312.174491-1-sean@mess.org
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2024-01-12 17:51:36 +01:00
Uwe Kleine-König 881791886b pwm: cros-ec: Drop documentation for dropped struct member
Recently an unused member was removed from struct cros_ec_pwm_device,
but the kernel doc wasn't adapted accordingly. Catch up and drop the
documentation, too.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202312190757.O4M9dsln-lkp@intel.com/
Fixes: 6c4406ce60 ("pwm: cros-ec: Drop unused member from driver private data")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 18:28:24 +01:00
Uwe Kleine-König 4430d02dc1 pwm: lpc18xx-sct: Don't modify the cached period of other PWM outputs
Even though the hardware only supports a single period for all PWM
outputs, modifying the other (disabled) outputs's period is strange and
wrong. Only the pwm core is supposed to update these values.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 17:01:43 +01:00
Uwe Kleine-König b41ccc3bc9 pwm: meson: Simplify using dev_err_probe()
Using dev_err_probe() emitting an error message mentioning a return
value and returning that value can be done in a single statement. Make
use of that to simplify the probe part of the driver. This has the
additional advantage to emit the symbolic name for the error instead of
the integer error value.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:25:53 +01:00
Uwe Kleine-König d9eb24c6f4 pwm: stmpe: Silence duplicate error messages
stmpe_reg_read() and stmpe_reg_write() already emit error messages when
they fail. So the extra error messages in the pwm driver are only little
useful. They are useful in some situation, as they give a bit of context
to the failing register write. So don't remove them but degrade them to
dev_dbg().

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:25:43 +01:00
Uwe Kleine-König efb704abed pwm: Reduce number of pointer dereferences in pwm_device_request()
pwm->chip and pwm->chip->ops are used several times in this function.
Introduce local variables for these.

There is no semantical change, but with ARCH=arm, allmodconfig and
gcc-13 bloat-o-meter reports a slight improvement:

	add/remove: 1/1 grow/shrink: 1/1 up/down: 8/-36 (-28)
	Function                                     old     new   delta
	pwm_apply_state                              476     480      +4
	__initcall__kmod_core__307_1092_pwm_debugfs_init4       -       4      +4
	__initcall__kmod_core__307_1090_pwm_debugfs_init4       4       -      -4
	pwm_request_from_chip                        628     596     -32
	Total: Before=15091, After=15063, chg -0.19%

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:24:44 +01:00
Uwe Kleine-König d243221dc9 pwm: crc: Use consistent variable naming for driver data
All but one local variable of type pointer to struct crystalcove_pwm are
called "crc_pwm", the one outlier is called "pwm" which is usually
reserved for variables of type pointer to struct pwm_device.

So rename that one "pwm" to "crc_pwm" for consistency.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:23:24 +01:00
Uwe Kleine-König 01b571fbba pwm: omap-dmtimer: Drop locking
The pwm driver only provides a single PWM line, so there are no concurrent
calls of the callbacks from different consumers. A single consumer is
expected not to do concurrent calls into the pwm framework. So there is
nothing to serialize and the lock can go away.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:22:50 +01:00
Sean Young fcc7607293 pwm: bcm2835: Allow PWM driver to be used in atomic context
clk_get_rate() may do a mutex lock. Fetch the clock rate once, and prevent
rate changes using clk_rate_exclusive_get().

Signed-off-by: Sean Young <sean@mess.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:12:32 +01:00
Sean Young 7170d3beaf pwm: Make it possible to apply PWM changes in atomic context
Some PWM devices require sleeping, for example if the pwm device is
connected over I2C. However, many PWM devices could be used from atomic
context, e.g. memory mapped PWM. This is useful for, for example, the
pwm-ir-tx driver which requires precise timing. Sleeping causes havoc
with the generated IR signal.

Since not all PWM devices can support atomic context, we also add a
pwm_might_sleep() function to check if is not supported.

Signed-off-by: Sean Young <sean@mess.org>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:07:06 +01:00
Sean Young 752193da3f pwm: renesas: Remove unused include
No mutex is used in this driver.

Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:07:05 +01:00
Sean Young c748a6d77c pwm: Rename pwm_apply_state() to pwm_apply_might_sleep()
In order to introduce a pwm api which can be used from atomic context,
we will need two functions for applying pwm changes:

	int pwm_apply_might_sleep(struct pwm *, struct pwm_state *);
	int pwm_apply_atomic(struct pwm *, struct pwm_state *);

This commit just deals with renaming pwm_apply_state(), a following
commit will introduce the pwm_apply_atomic() function.

Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> # for input
Acked-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Acked-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:07:04 +01:00
Thierry Reding 80943bbdcf pwm: Stop referencing pwm->chip
Drivers have access to the chip via a function argument already, so
there is no need to reference it via the PWM device.

Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:14 +01:00
Philipp Zabel 19f1016ea9 pwm: stm32: Fix enable count for clk in .probe()
Make the driver take over hardware state without disabling in .probe()
and enable the clock for each enabled channel.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
[ukleinek: split off from a patch that also implemented .get_state()]
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fixes: 7edf736920 ("pwm: Add driver for STM32 plaftorm")
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:14 +01:00
Philipp Zabel e56ec7b752 pwm: stm32: Implement .get_state()
Implement the &pwm_ops->get_state callback so drivers can inherit PWM
state set by the bootloader.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
[ukl: split off from a patch that also fixes clk enable count in .probe()]
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:14 +01:00
Philipp Zabel 41fa8f57c0 pwm: stm32: Use hweight32 in stm32_pwm_detect_channels
Use hweight32() to count the CCxE bits in stm32_pwm_detect_channels().
Since the return value is assigned to chip.npwm, change it to unsigned
int as well.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:14 +01:00
Philipp Zabel c0504f59ce pwm: stm32: Make ch parameter unsigned
The channel parameter is only ever set to pwm->hwpwm.
Make it unsigned int as well.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:14 +01:00
Philipp Zabel e495f47274 pwm: stm32: Replace write_ccrx with regmap_write
The TIM_CCR1...4 registers are consecutive, so replace the switch
case with a simple calculation. Since ch is known to be in the 0...3
range (it is set to hwpwm < npwm <= 4), drop the unnecessary error
handling. The return value was not checked anyway. What remains does
not warrant keeping the write_ccrx() function around, so instead call
regmap_write() directly at the singular call site.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:14 +01:00
Rob Herring 7ee2273197 pwm: Use device_get_match_data()
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.

As these drivers only do DT based matching, of_match_device() will never
return NULL if we've gotten to probe(). Therefore, the NULL check and
error returns can be dropped.

Signed-off-by: Rob Herring <robh@kernel.org>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König b0445a18d3 pwm: Narrow scope of struct pwm_device pointer
In the expression determining the size of the allocation for chip->pwms
it's more natural to use sizeof(*chip->pwms) than sizeof(*pwm). With
that changed, the variable pwm is only used in a for loop and its scope
can be reduced accordingly.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König 1c9a2ad84f pwm: jz4740: Add trailing \n to error messages
Error messages are supposed to end in \n. Add the line terminator to the
two error messages that lack this.

Suggested-by: Paul Cercueil <paul@crapouillou.net>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König fb1b517fd8 pwm: tiehrpwm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
#ifdef can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König 5d5a0aa5e2 pwm: tiecap: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
#ifdef can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König 3d67277607 pwm: stm32: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
__maybe_unused can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König 39dfb60c72 pwm: stm32-lp: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
__maybe_unused can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König e9ebab624d pwm: samsung: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
#ifdef can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König 9676b40e18 pwm: imx-tpm: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
__maybe_unused can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König 30b5b066fa pwm: dwc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
#ifdef can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König d6b81be1f5 pwm: brcmstb: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
#ifdef can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Acked-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König fac37751c4 pwm: berlin: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
#ifdef can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König a7bab37f87 pwm: atmel-tcb: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
#ifdef can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König ded38f874e pwm: atmel-hlcdc: Use DEFINE_SIMPLE_DEV_PM_OPS for PM functions
This macro has the advantage over SIMPLE_DEV_PM_OPS that we don't have to
care about when the functions are actually used, so the corresponding
#ifdef can be dropped.

Also make use of pm_ptr() to discard all PM related stuff if CONFIG_PM
isn't enabled.

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König 6c4406ce60 pwm: cros-ec: Drop unused member from driver private data
.dev is unused since the driver was introduced in commit 1f0d3bb027
("pwm: Add ChromeOS EC PWM driver"). Drop it.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König 0360a48733 pwm: Mention PWM chip ID in /sys/kernel/debug/pwm
While it's not hard to match the entries from /sys/kernel/debug/pwm to
the corresponding pwmchip in /sys/class/pwm, it's a bit simpler to have
the number mentioned in /sys/kernel/debug/pwm.

Link: https://lore.kernel.org/r/20230808165250.942396-3-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:13 +01:00
Uwe Kleine-König 54c86dd20b pwm: Replace PWM chip unique base by unique ID
Traditionally each PWM device had a unique ID stored in the "pwm" member
of struct pwm_device. However this number was hardly used and dropped
in the previous commit. To identify a certain PWM you're supposed to use
the chip's ID and the hwpwm of the PWM device now.

With the PWM chip base gone PWM chips can get their IDs better and
simpler using an idr.

This is expected to change the numbering of PWM chips, but nothing
should rely on the numbering anyhow.

Other than that the side effects are:

 - The PWM chip IDs are smaller and in most cases consecutive.
 - The ordering in /sys/kernel/debug/pwm is ordered by ascending PWM
   chip ID.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:12 +01:00
Uwe Kleine-König f3e25e68ce pwm: Drop unused member "pwm" from struct pwm_device
This member is only assigned to and never read. So drop it.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-12-20 16:04:12 +01:00
Florian Fainelli 4e7a8dbd2b pwm: bcm2835: Fix NPD in suspend/resume
When 119a508c4d ("pwm: bcm2835: Add support for suspend/resume") was
sent out on October 11th,, there was still a call to
platform_set_drvdata() which would ensure that the driver private data
structure could be used in bcm2835_pwm_{suspend,resume}.

A cleanup now merged as commit commit 2ce7b7f670 ("pwm: bcm2835:
Simplify using devm functions") removed that call which would now cause
a NPD in bcm2835_pwm_{suspend,resume} as a consequence.

Fixes: 119a508c4d ("pwm: bcm2835: Add support for suspend/resume")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/linux-pwm/20231113164632.2439400-1-florian.fainelli@broadcom.com
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
2023-11-21 11:09:32 +01:00
Dan Carpenter a2da597ff6 pwm: samsung: Fix a bit test in pwm_samsung_resume()
The PWMF_REQUESTED enum is supposed to be used with test_bit() and not
used as in a bitwise AND.  In this specific code the flag will never be
set so the function is effectively a no-op.

Fixes: e3fe982b2e ("pwm: samsung: Put per-channel data into driver data")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-11-10 09:20:48 +01:00
Uwe Kleine-König 40592064a1 pwm: samsung: Document new member .channel in struct samsung_pwm_chip
My earlier commit reworking how driver data is tracked added a new
member to struct samsung_pwm_chip but failed to add matching
documentation. Make up leeway.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202310130404.uQ33q5Dk-lkp@intel.com/
Fixes: e3fe982b2e ("pwm: samsung: Put per-channel data into driver data")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-11-03 12:00:41 +01:00
Florian Fainelli 119a508c4d pwm: bcm2835: Add support for suspend/resume
Similar to other drivers, we need to make sure that the clock is
disabled during suspend and re-enabled during resume.

Reported-by: Angus Clark <angus.clark@broadcom.com>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Florian Fainelli aacbd65436 pwm: brcmstb: Checked clk_prepare_enable() return value
Check the clk_prepare_enable() return value and propagate it.

Suggested-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Florian Fainelli e9bc441154 pwm: brcmstb: Utilize appropriate clock APIs in suspend/resume
The suspend/resume functions currently utilize
clk_disable()/clk_enable() respectively which may be no-ops with certain
clock providers such as SCMI. Fix this to use clk_disable_unprepare()
and clk_prepare_enable() respectively as we should.

Fixes: 3a9f595702 ("pwm: Add Broadcom BCM7038 PWM controller support")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Rob Herring 87e51b76c9 pwm: pxa: Explicitly include correct DT includes
The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König 896c450960 pwm: cros-ec: Simplify using devm_pwmchip_add() and dev_err_probe()
Using devm_pwmchip_add() allows to drop pwmchip_remove() from the remove
function which makes this function empty. Then there is no user of
drvdata left and platform_set_drvdata() can be dropped, too.

Further simplify and improve error returning using dev_err_probe().

Link: https://lore.kernel.org/r/20230929161918.2410424-12-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König 9608405bda pwm: samsung: Consistently use the same name for driver data
The driver uses mostly "chip" to name samsung_pwm_chip pointers:

$ git grep -Pho 'samsung_pwm_chip \*[a-zA-Z0-9_]+(*nla:[a-zA-Z0-9_(])' v6.5-rc1 -- drivers/pwm/pwm-samsung.c | sort | uniq -c
     10 samsung_pwm_chip *chip
      6 samsung_pwm_chip *our_chip
      1 samsung_pwm_chip *pwm

However "chip" is supposed to be used for struct pwm_chip pointers and
"pwm" for struct pwm_device pointers. So consistently use "our_chip".

Link: https://lore.kernel.org/r/20230929161918.2410424-11-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König dfbf937916 pwm: vt8500: Simplify using devm functions
With devm_clk_get_prepared() the call to clk_unprepare() can be dropped
from the error path and the remove callback. With devm_pwmchip_add()
pwmchip_remove() can be dropped. Then the remove callback is empty and
can go away, too. With vt8500_pwm_remove() the last user of
platform_get_drvdata() is gone and so platform_set_drvdata() can be
dropped, too.

Also use dev_err_probe() for simplified (and improved) error reporting.

Link: https://lore.kernel.org/r/20230929161918.2410424-10-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König 21c0e1aaf7 pwm: sprd: Simplify using devm_pwmchip_add() and dev_err_probe()
Using devm_pwmchip_add() allows to drop pwmchip_remove() from the remove
function which makes this function empty. Then there is no user of
drvdata left and platform_set_drvdata() can be dropped, too.

Further simplify and improve error returning using dev_err_probe().

Link: https://lore.kernel.org/r/20230929161918.2410424-9-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König d8a2f6f26a pwm: sprd: Provide a helper to cast a chip to driver data
Similar to most other PWM drivers provide a static inline function to
calculate driver data from a given pwmchip.

Link: https://lore.kernel.org/r/20230929161918.2410424-8-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König 4f9ab6902b pwm: spear: Simplify using devm functions
With devm_clk_get_prepared() the call to clk_unprepare() can be dropped
from the error path and the remove callback. With devm_pwmchip_add()
pwmchip_remove() can be dropped. Then the remove callback is empty and
can go away, too. With spear_pwm_remove() the last user of
platform_get_drvdata() is gone and so platform_set_drvdata() can be
dropped, too.

Also use dev_err_probe() for simplified (and improved) error reporting.

Link: https://lore.kernel.org/r/20230929161918.2410424-7-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König 05c9b6f8e5 pwm: mtk-disp: Simplify using devm_pwmchip_add()
With devm_pwmchip_add() pwmchip_remove() can be dropped from the remove
callback. Then the remove callback is empty and can go away, too. With
mtk_disp_pwm_remove() the last user of platform_get_drvdata() is gone and
so platform_set_drvdata() can be dropped, too.

Also use dev_err_probe() for simplified (and improved) error reporting.

Link: https://lore.kernel.org/r/20230929161918.2410424-6-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König 92fcd5b682 pwm: imx-tpm: Simplify using devm functions
With devm_clk_get_enabled() the call to clk_disable_unprepare() can be
dropped from the error path and the remove callback. With
devm_pwmchip_add() pwmchip_remove() can be dropped. Then the remove
callback is empty and can go away, too.

Also use dev_err_probe() for simplified (and improved) error reporting.

Link: https://lore.kernel.org/r/20230929161918.2410424-5-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König 5af615f8ac pwm: brcmstb: Simplify using devm functions
With devm_clk_get_enabled() the call to clk_disable_unprepare() can be
dropped from the error path and the remove callback. With
devm_pwmchip_add() pwmchip_remove() can be dropped. Then the remove
callback is empty and can go away, too.

Also use dev_err_probe() for simplified (and improved) error reporting.

Link: https://lore.kernel.org/r/20230929161918.2410424-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König 2ce7b7f670 pwm: bcm2835: Simplify using devm functions
With devm_clk_get_enabled() the call to clk_disable_unprepare() can be
dropped from the error path and the remove callback. With
devm_pwmchip_add() pwmchip_remove() can be dropped. Then the remove
callback is empty and can go away, too. With bcm2835_pwm_remove() the only
user of platform_get_drvdata() is gone and so platform_set_drvdata() can
be dropped from .probe(), too.

Also use dev_err_probe() for simplified (and improved) error reporting.

Link: https://lore.kernel.org/r/20230929161918.2410424-3-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Uwe Kleine-König b498c14efd pwm: bcm-iproc: Simplify using devm functions
With devm_clk_get_enabled() the call to clk_disable_unprepare() can be
dropped from the error path and the remove callback. With
devm_pwmchip_add() pwmchip_remove() can be dropped. Then the remove
callback is empty and can go away, too.

Also use dev_err_probe() for simplified (and improved) error reporting.

Link: https://lore.kernel.org/r/20230929161918.2410424-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:18 +02:00
Ben Dooks 4aff152d14 pwm: dwc: add PWM bit unset in get_state call
If we are not in PWM mode, then the output is technically a 50%
output based on a single timer instead of the high-low based on
the two counters. Add a check for the PWM mode in dwc_pwm_get_state()
and if DWC_TIM_CTRL_PWM is not set, then return a 50% cycle.

This may only be an issue on initialisation, as the rest of the
code currently assumes we're always going to have the extended
PWM mode using two counters.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230907161242.67190-4-ben.dooks@codethink.co.uk
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Ben Dooks 81432e2e51 pwm: dwc: make timer clock configurable
Add a configurable clock base rate for the pwm as when being built
for non-PCI the block may be sourced from an internal clock.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230907161242.67190-3-ben.dooks@codethink.co.uk
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Ben Dooks 721ee18848 pwm: dwc: split pci out of core driver
Moving towards adding non-pci support for the driver, move the pci
parts out of the core into their own module. This is partly due to
the module_driver() code only being allowed once in a module and also
to avoid a number of #ifdef if we build a single file in a system
without pci support.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20230907161242.67190-2-ben.dooks@codethink.co.uk
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König 6dbf23f5cf pwm: berlin: Simplify using devm functions
With devm_clk_get_enabled() the call to clk_disable_unprepare() can be
dropped from the error path and the remove callback. With
devm_pwmchip_add() pwmchip_remove() can be dropped. Then the remove
callback is empty and can go away, too.

Link: https://lore.kernel.org/r/20230718175545.3946935-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König a6e5654e0b pwm: Drop pwm_[sg]et_chip_data()
The semantic of chip_data is a bit surprising as it's cleared when
pwm_put() is called. Also there is a big overlap with the standard driver
data.

All drivers were adapted to not make use of chip_data any more, so it can
go away.

Link: https://lore.kernel.org/r/20230705080650.2353391-9-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König 82adc1b268 pwm: cros-ec: Put per-channel data into driver data
Instead of an allocation of a single u16 per channel, allocate them all in
a single chunk which greatly reduces memory fragmentation and also the
overhead to track the allocated memory. Also put the channel data in
driver data where it's cheaper to determine the address (no function call
involved, just a trivial pointer addition).

This also allows to get rid of the request and free callbacks.

The only cost is that the channel data is allocated early, and even for
unused channels.

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://lore.kernel.org/r/20230705080650.2353391-8-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König 2d6812b41e pwm: sti: Reduce number of allocations and drop usage of chip_data
Instead of using one allocation per capture channel, use a single one. Also
store it in driver data instead of chip data.

This has several advantages:

 - driver data isn't cleared when pwm_put() is called
 - Reduces memory fragmentation

Also register the pwm chip only after the per capture channel data is
initialized as the capture callback relies on this initialization and it
might be called even before pwmchip_add() returns.

It would be still better to have struct sti_pwm_compat_data and the
per-channel data struct sti_cpt_ddata in a single memory chunk, but that's
not easily possible because the number of capture channels isn't known yet
when the driver data struct is allocated.

Fixes: e926b12c61 ("pwm: Clear chip_data in pwm_put()")
Reported-by: George Stark <gnstark@sberdevices.ru>
Fixes: c97267ae83 ("pwm: sti: Add PWM capture callback")
Link: https://lore.kernel.org/r/20230705080650.2353391-7-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König ec63391a0d pwm: renesas: Drop usage of pwm_[gs]et_chip_data()
Instead of distributing the driver's bookkeeping over 5 (i.e.
TPU_CHANNEL_MAX + 1) separately allocated memory chunks, put all together
in struct tpu_device. This reduces the number of memory allocations and
so fragmentation and maybe even the number of cache misses. Also
&tpu->tpd[pwm->hwpwm] is cheaper to evaluate than pwm_get_chip_data(pwm)
as the former is just an addition in machine code while the latter involves
a function call.

Link: https://lore.kernel.org/r/20230705080650.2353391-6-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König 06cc476775 pwm: lp3943: Drop usage of pwm_[gs]et_chip_data()
Instead of distributing the driver's bookkeeping over 3 (i.e.
LP3943_NUM_PWMS + 1) separately allocated memory chunks, put all together
in struct lp3943_pwm. This reduces the number of memory allocations and
so fragmentation and maybe even the number of cache misses. Also
&lp3943_pwm->pwm_map[pwm->hwpwm] is cheaper to evaluate than
pwm_get_chip_data(pwm) as the former is just an addition in machine code
while the latter involves a function call.

Link: https://lore.kernel.org/r/20230705080650.2353391-5-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König 89c8de78ce pwm: jz4740: Put per-channel clk into driver data
Stop using chip_data which is about to go away. Instead track the
per-channel clk in struct jz4740_pwm_chip.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20230705080650.2353391-4-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König e3fe982b2e pwm: samsung: Put per-channel data into driver data
Instead of allocating extra data in .request() provide the needed memory
in struct samsung_pwm_chip. This reduces the number of allocations. Even
though now all 5 channel structs are allocated this is probably
outweighed by the reduced overhead to track up to 6 smaller allocations.

Link: https://lore.kernel.org/r/20230705080650.2353391-3-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König 1b2af7bb75 pwm: berlin: Put per-channel config into driver data
Instead of allocating extra data in .request() provide the needed memory
in struct berlin_pwm_chip. This reduces the number of allocations. A
side effect is that on suspend and resume the state for all four
channels is always saved and restored. This is easier (and probably
quicker) than looking up the matching pwm_device and checking its
PWMF_REQUESTED bit.

Link: https://lore.kernel.org/r/20230705080650.2353391-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König 91a69d38cf pwm: crc: Allow compilation as module and with COMPILE_TEST
The driver compiles just fine as a module. The parent driver's Kconfig
symbol already depends on X86 || COMPILE_TEST, so X86 can just be
dropped from the dependencies allowing compilation on other platforms
than x86.

Link: https://lore.kernel.org/r/20230804142707.412137-3-u.kleine-koenig@pengutronix.de
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König 384461abca pwm: Manage owner assignment implicitly for drivers
Instead of requiring each driver to care for assigning the owner member
of struct pwm_ops, handle that implicitly using a macro. Note that the
owner member has to be moved to struct pwm_chip, as the ops structure
usually lives in read-only memory and so cannot be modified.

The upside is that new low level drivers cannot forget the assignment and
save one line each. The pwm-crc driver didn't assign .owner, that's not
a problem in practice though as the driver cannot be compiled as a
module.

Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com> # Intel LPSS
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> # pwm-{bcm,brcm}*.c
Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com> # sun4i
Acked-by: Andi Shyti <andi.shyti@kernel.org>
Acked-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp> # pwm-visconti
Acked-by: Heiko Stuebner <heiko@sntech.de> # pwm-rockchip
Acked-by: Michael Walle <michael@walle.cc> # pwm-sl28cpld
Acked-by: Neil Armstrong <neil.armstrong@linaro.org> # pwm-meson
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20230804142707.412137-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Uwe Kleine-König 7a3663c2e4 pwm: jz4740: Consistently name driver data "jz"
Most but not all pointers to driver data are already called "jz":

	$ git grep 'struct jz4740_pwm_chip \*' v6.5-rc1 -- drivers/pwm/pwm-jz4740.c
	v6.5-rc1:drivers/pwm/pwm-jz4740.c:static inline struct jz4740_pwm_chip *to_jz4740(struct pwm_chip *chip)
	v6.5-rc1:drivers/pwm/pwm-jz4740.c:static bool jz4740_pwm_can_use_chn(struct jz4740_pwm_chip *jz,
	v6.5-rc1:drivers/pwm/pwm-jz4740.c:      struct jz4740_pwm_chip *jz = to_jz4740(chip);
	v6.5-rc1:drivers/pwm/pwm-jz4740.c:      struct jz4740_pwm_chip *jz = to_jz4740(chip);
	v6.5-rc1:drivers/pwm/pwm-jz4740.c:      struct jz4740_pwm_chip *jz = to_jz4740(chip);
	v6.5-rc1:drivers/pwm/pwm-jz4740.c:      struct jz4740_pwm_chip *jz4740 = to_jz4740(pwm->chip);
	v6.5-rc1:drivers/pwm/pwm-jz4740.c:      struct jz4740_pwm_chip *jz4740;

Adapt the two variables called "jz4740" to use the same name for
consistency.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Link: https://lore.kernel.org/r/20230808062608.897710-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-13 10:07:17 +02:00
Conor Dooley 162844744f pwm: microchip-core: Convert SOC_MICROCHIP_POLARFIRE to ARCH_MICROCHIP_POLARFIRE
As part of converting RISC-V SOC_FOO symbols to ARCH_FOO to match the
use of such symbols on other architectures, convert the Microchip FPGA
PWM driver to use the new symbol.

Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-06 11:04:25 +02:00
Ruan Jinjie 7818f0bcc1 pwm: omap-dmtimer: Remove redundant of_match_ptr()
The driver depends on CONFIG_OF, it is not necessary to use
of_match_ptr() here.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-06 10:37:28 +02:00
Ruan Jinjie 2992e07038 pwm: atmel: Remove redundant of_match_ptr()
The driver depends on CONFIG_OF, it is not necessary to use
of_match_ptr() here.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-10-06 10:37:27 +02:00
Linus Torvalds 8d844b3518 pwm: Changes for v6.6-rc1
This contains various cleanups and fixes across the board.
 -----BEGIN PGP SIGNATURE-----
 
 iQJNBAABCAA3FiEEiOrDCAFJzPfAjcif3SOs138+s6EFAmT55DMZHHRoaWVycnku
 cmVkaW5nQGdtYWlsLmNvbQAKCRDdI6zXfz6zoZHtEACJJRp36f/VBNHIkdIHlgnY
 OA1ScjwsLSmavWo6IJtGM/iAawnNBnKyMNymWjjs6240cNlXmIjQBvEX0zkRVsrp
 kuREZS0o5yS1kaM9QMXpur6HLNqwKxFGIzvUlcN2IB+myCBxfEQ/KlR3u3vRdQyH
 yB+9dvpAS1iRU957WcmdAtnid1j3mwxbFnNBMPp9iV7iH0Lg1TDSHuf1OCxc8lnP
 BZhS0zOjLUY8Eyo/pDkI9IIA4lXIg/JH9Ux4n88Ag84UiU/Q12APyT6R5nClK8Cr
 0+LUHzjL4ZJbGdUkHyJtfzIGaO0Qy8TTgn7irPQChdIVTehhH5T4Uzl7v0EFudWi
 qz3BeGnOlFlhQG0WdAwH8pYYeTIVOn5HjjXQunmk36e1b+FNg5baQZ7gInry172b
 HT9KmDGfFBaDME1mZ4IayCvmjRIuoFWI6GtS/ykPBOTd58CjytMJD+khuTUwkUSd
 D5KAakc70JYBHQLzsRZExiP5RwxJ8LChmwF4yBfROF0S7KCL84R4pbEMLZ0ko08g
 bcxyZ8yHoTEpRxg332B1M/A/KFAMPiit0qK3LnuGdP0B73GFBb9mGvgwb6vwzRx1
 Vo6Ewr8A3wZAL56rzXPFvabnMblzvHbuNQTMFkJLhA+doI4n3Oq+KW1u7Cf4ygEF
 qGOFsQsphAHZFrIob8xleg==
 =kax5
 -----END PGP SIGNATURE-----

Merge tag 'pwm/for-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm

Pull pwm updates from Thierry Reding:
 "Various cleanups and fixes across the board"

* tag 'pwm/for-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (31 commits)
  pwm: lpc32xx: Remove handling of PWM channels
  pwm: atmel: Simplify using devm functions
  dt-bindings: pwm: brcm,kona-pwm: convert to YAML
  pwm: stmpe: Handle errors when disabling the signal
  pwm: stm32: Simplify using devm_pwmchip_add()
  pwm: stm32: Don't modify HW state in .remove() callback
  pwm: Fix order of freeing resources in pwmchip_remove()
  pwm: ntxec: Use device_set_of_node_from_dev()
  pwm: ntxec: Drop a write-only variable from driver data
  pwm: pxa: Don't reimplement of_device_get_match_data()
  pwm: lpc18xx-sct: Simplify using devm_clk_get_enabled()
  pwm: atmel-tcb: Don't track polarity in driver data
  pwm: atmel-tcb: Unroll atmel_tcb_pwm_set_polarity() into only caller
  pwm: atmel-tcb: Put per-channel data into driver data
  pwm: atmel-tcb: Fix resource freeing in error path and remove
  pwm: atmel-tcb: Harmonize resource allocation order
  pwm: Drop unused #include <linux/radix-tree.h>
  pwm: rz-mtu3: Fix build warning 'num_channel_ios' not described
  pwm: Remove outdated documentation for pwmchip_remove()
  pwm: atmel: Enable clk when pwm already enabled in bootloader
  ...
2023-09-07 18:05:58 -07:00
Vladimir Zapolskiy 4aae44f658 pwm: lpc32xx: Remove handling of PWM channels
Because LPC32xx PWM controllers have only a single output which is
registered as the only PWM device/channel per controller, it is known in
advance that pwm->hwpwm value is always 0. On basis of this fact
simplify the code by removing operations with pwm->hwpwm, there is no
controls which require channel number as input.

Even though I wasn't aware at the time when I forward ported that patch,
this fixes a null pointer dereference as lpc32xx->chip.pwms is NULL
before devm_pwmchip_add() is called.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fixes: 3d2813fb17 ("pwm: lpc32xx: Don't modify HW state in .probe() after the PWM chip was registered")
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-08-22 10:14:16 +02:00
Arnd Bergmann 10d3340441 mfd: rz-mtu3: Link time dependencies
The new set of drivers for RZ/G2L MTU3a tries to enable compile-testing the
individual client drivers even when the MFD portion is disabled but gets it
wrong, causing a link failure when the core is in a loadable module but the
other drivers are built-in:

x86_64-linux-ld: drivers/pwm/pwm-rz-mtu3.o: in function `rz_mtu3_pwm_apply':
pwm-rz-mtu3.c:(.text+0x4bf): undefined reference to `rz_mtu3_8bit_ch_write'
x86_64-linux-ld: pwm-rz-mtu3.c:(.text+0x509): undefined reference to `rz_mtu3_disable'

arm-linux-gnueabi-ld: drivers/counter/rz-mtu3-cnt.o: in function `rz_mtu3_cascade_counts_enable_get':
rz-mtu3-cnt.c:(.text+0xbec): undefined reference to `rz_mtu3_shared_reg_read'

It seems better not to add the extra complexity here but instead just use
a normal hard dependency, so remove the #else portion in the header along
with the "|| COMPILE_TEST". This could also be fixed by having slightly more
elaborate Kconfig dependencies or using the cursed 'IS_REACHABLE()' helper,
but in practice it's already possible to compile-test all these drivers
by enabling the mtd portion.

Fixes: 254d3a7274 ("pwm: Add Renesas RZ/G2L MTU3a PWM driver")
Fixes: 0be8907359 ("counter: Add Renesas RZ/G2L MTU3a counter driver")
Fixes: 654c293e16 ("mfd: Add Renesas RZ/G2L MTU3a core driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thierry Reding <thierry.reding@gmail.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20230719090430.1925182-1-arnd@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
2023-08-18 21:48:04 +01:00
Uwe Kleine-König b22bb0d6a8 pwm: atmel: Simplify using devm functions
For all resources used by the driver there is a devm variant to allocate
these. This simplifies the error path in the probe callback and allows
to drop the remove callback.

While at it also use dev_err_probe() to compact returning an error.

With the remove callback gone, there is no user of driver data left, so
the call to platform_set_drvdata() can also be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-07-28 10:15:44 +02:00
Uwe Kleine-König b2c71e9f8d pwm: stmpe: Handle errors when disabling the signal
Before the pwm framework implementedatomic updates (with the .apply()
callback) the .disable() callback returned void. This is still visible
in the stmpe driver which drops errors in the disable path.

Improve the driver to forward failures in stmpe_24xx_pwm_disable() to
the caller of pwm_apply_state().

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2023-07-28 09:49:18 +02:00