Commit graph

1750 commits

Author SHA1 Message Date
Linus Torvalds
2d945dde7f This is the usual collection of primarily clk driver updates. The big part of
the diff is all the new Qualcomm clk drivers added for a few SoCs they're
 working on. The other two vendors with significant work this cycle are Renesas
 and Amlogic. Renesas adds a bunch of clks to existing drivers and supports some
 new SoCs while Amlogic is starting a significant refactoring to simplify their
 code.
 
 The core framework gained a pair of helpers to get the 'struct device' or
 'struct device_node' associated with a 'struct clk_hw'. Some associated KUnit
 tests were added for these simple helpers as well. Beyond that core change
 there are lots of little fixes throughout the clk drivers for the stuff we see
 every day, wrong clk driver data that affects tree topology or supported
 frequencies, etc. They're not found until the clks are actually used by some
 consumer device driver.
 
 New Drivers:
  - Global, display, gpu, video, camera, tcsr, and rpmh clock controller for the
    Qualcomm Milos SoC
  - Camera, display, GPU, and video clock controllers for Qualcomm QCS615
  - Video clock controller driver for Qualcomm SM6350
  - Camera clock controller driver for Qualcomm SC8180X
  - I3C clocks and resets on Renesas RZ/G3E
  - Expanded Serial Peripheral Interface (xSPI) clocks and resets on
    Renesas RZ/V2H(P) and RZ/V2N
  - SPI (RSPI) clocks and resets on Renesas RZ/V2H(P)
  - SDHI and I2C clocks on Renesas RZ/T2H and RZ/N2H
  - Ethernet clocks and resets on Renesas RZ/G3E
  - Initial support for the Renesas RZ/T2H (R9A09G077) and RZ/N2H
    (R9A09G087) SoCs
  - Ethernet clocks and resets on Renesas RZ/V2H and RZ/V2N
  - Timer, I2C, watchdog, GPU, and USB2.0 clocks and resets on Renesas
    RZ/V2N
 
 Updates:
  - Support atomic PWMs in the PWM clk driver
  - clk_hw_get_dev() and clk_hw_get_of_node() helpers
  - Replace round_rate() with determine_rate() in various clk drivers
  - Convert clk DT bindings to DT schema format for DT validation
  - Various clk driver cleanups and refactorings from static analysis tools and
    possibly real humans
  - A lot of little fixes here and there to things like clk tree topology,
    missing frequencies, flagging clks as critical, etc. The full details are in
    the commits and sub-tree merge logs
 -----BEGIN PGP SIGNATURE-----
 
 iQJIBAABCAAyFiEE9L57QeeUxqYDyoaDrQKIl8bklSUFAmiLljkUHHN3Ym95ZEBj
 aHJvbWl1bS5vcmcACgkQrQKIl8bklSVR1BAAm5hnFdYvNX/AYK+bNNbb/YkbveGr
 wxrZFjd/1QEZii7UBBOENLjvbrxT4N93TGuwuHOy+iz53X4mWg1BST0RENtmks9v
 rys7suEkDVA7KoDEbcvbUhLbLObEQvr3sxurl2mvq563y02hkJ+rt3kDqdCn/MFK
 fUfqZ79oPLaMULy3XwFyrEQEcxqQTX7i+j1atCB4TPmBSu3R5WMsCS+IVKPCuxCF
 qcan5hCXakv4gBE/jF9x/u28j0m9v16uB2O/7sH3uDzHo/FxShBmC53Bj2Mtaf2w
 lSKhEngCAMItU2LtruO2szpsmoy9EZTIqzELr5GJGXFDQDHiTzcigRtD5MCWjdG1
 aapgWs47Yslh0M+d8Im81hu1YaLGDuoY7QiOVMN/htn0nPEozU1farKJbD3/gj9U
 C6648EXYa/dqDBRRHeqLi4n1RK0Fzb15VvsanKn1nLy+cOvzNI4bpJjEJlUQjZMN
 8MzvzBgLNsydDQC5I8JAPPK2Fcdpk3KpchphZrXLZY8iRco5kvx1mRjh90Lvr8N8
 rmpUC6p1BdEIGhL+NAh7qCz9DOKfsaFr13tHpqD/PItzfHIyd7mss+7GSD6WCa/b
 MduE9172Uq0mY8ZnWe0vV7/+s9GE7oTsxdMC6oF5yTXRIpog7evkUqNyXhpNTxgS
 C2DLCDhaqpHI28c=
 =S+dB
 -----END PGP SIGNATURE-----

Merge tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux

Pull clk updates from Stephen Boyd:
 "This is the usual collection of primarily clk driver updates.

  The big part of the diff is all the new Qualcomm clk drivers added for
  a few SoCs they're working on. The other two vendors with significant
  work this cycle are Renesas and Amlogic. Renesas adds a bunch of clks
  to existing drivers and supports some new SoCs while Amlogic is
  starting a significant refactoring to simplify their code.

  The core framework gained a pair of helpers to get the 'struct device'
  or 'struct device_node' associated with a 'struct clk_hw'. Some
  associated KUnit tests were added for these simple helpers as well.

  Beyond that core change there are lots of little fixes throughout the
  clk drivers for the stuff we see every day, wrong clk driver data that
  affects tree topology or supported frequencies, etc. They're not found
  until the clks are actually used by some consumer device driver.

  New Drivers:
   - Global, display, gpu, video, camera, tcsr, and rpmh clock
     controller for the Qualcomm Milos SoC
   - Camera, display, GPU, and video clock controllers for Qualcomm
     QCS615
   - Video clock controller driver for Qualcomm SM6350
   - Camera clock controller driver for Qualcomm SC8180X
   - I3C clocks and resets on Renesas RZ/G3E
   - Expanded Serial Peripheral Interface (xSPI) clocks and resets on
     Renesas RZ/V2H(P) and RZ/V2N
   - SPI (RSPI) clocks and resets on Renesas RZ/V2H(P)
   - SDHI and I2C clocks on Renesas RZ/T2H and RZ/N2H
   - Ethernet clocks and resets on Renesas RZ/G3E
   - Initial support for the Renesas RZ/T2H (R9A09G077) and RZ/N2H
     (R9A09G087) SoCs
   - Ethernet clocks and resets on Renesas RZ/V2H and RZ/V2N
   - Timer, I2C, watchdog, GPU, and USB2.0 clocks and resets on Renesas
     RZ/V2N

  Updates:
   - Support atomic PWMs in the PWM clk driver
   - clk_hw_get_dev() and clk_hw_get_of_node() helpers
   - Replace round_rate() with determine_rate() in various clk drivers
   - Convert clk DT bindings to DT schema format for DT validation
   - Various clk driver cleanups and refactorings from static analysis
     tools and possibly real humans
   - A lot of little fixes here and there to things like clk tree
     topology, missing frequencies, flagging clks as critical, etc"

* tag 'clk-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: (216 commits)
  clk: clocking-wizard: Fix the round rate handling for versal
  clk: Fix typos
  clk: spacemit: ccu_pll: fix error return value in recalc_rate callback
  clk: tegra: periph: Make tegra_clk_periph_ops static
  clk: tegra: periph: Fix error handling and resolve unsigned compare warning
  clk: imx: scu: convert from round_rate() to determine_rate()
  clk: imx: pllv4: convert from round_rate() to determine_rate()
  clk: imx: pllv3: convert from round_rate() to determine_rate()
  clk: imx: pllv2: convert from round_rate() to determine_rate()
  clk: imx: pll14xx: convert from round_rate() to determine_rate()
  clk: imx: pfd: convert from round_rate() to determine_rate()
  clk: imx: frac-pll: convert from round_rate() to determine_rate()
  clk: imx: fracn-gppll: convert from round_rate() to determine_rate()
  clk: imx: fixup-div: convert from round_rate() to determine_rate()
  clk: imx: cpu: convert from round_rate() to determine_rate()
  clk: imx: busy: convert from round_rate() to determine_rate()
  clk: imx: composite-93: remove round_rate() in favor of determine_rate()
  clk: imx: composite-8m: remove round_rate() in favor of determine_rate()
  clk: qcom: Remove redundant pm_runtime_mark_last_busy() calls
  clk: imx: Remove redundant pm_runtime_mark_last_busy() calls
  ...
2025-07-31 13:36:27 -07:00
Linus Torvalds
602a067286 pwm: Two fixes for 6.17-rc1
Here contained are two fixes for the mediatek and the imx-tpm driver.
 Both are already old but (v4.12-rc1 and v5.2-rc1 respectively) given
 it's still very early in the development cycle I consider them fine to
 go in.
 
 The mediatek issue is that both period and duty_cycle were configured to
 higher values than requested. For most applications the period part is
 no tragedy, but a PWM that is configured for duty_cycle = 0 should
 really emit a constant inactive signal. That was noticed by an LED not
 being completely off in this case.
 
 For the imx-tpm PWM driver the fixed issue is that the first period is
 quite a bit too long under some circumstances. So it might take up to
 UINT32_MAX << 7 clock ticks until the PWM starts toggling. With an
 assumed input clock rate of 166 MHz (completely made up) that's 55
 minutes.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmiLNDwACgkQj4D7WH0S
 /k6zDQf9Fa2BdzsF82IwyYy4oQBOb1KIW7YzP8CwHzRBITnq09EA2zRV8cGE7Ohk
 c/QMi9ILcMYwRXKk3kJIqGUY5HYcPX2yh21pNTatBTh47OJZnoBV1tbDEQbCLM55
 tS3fd3CduHdTP05j1X5QDEvsEhb9xKbUvAZ2z0jMX/6aOE+wMG1hq46GTQfAmewA
 pbyaGQk+0C1E4qONJ2eJz7zmkrPRa++EWusiOy7zfgQyf9GuX/PHftIiemabq+fP
 +WG4+nxVafHhmKg1b7JoGixXhHobTOiWnKTpBJCcvrqgIIfOgiDxb28bxPZibi04
 IDZNZUyXlnRikENbF7mfP1ICL1ygLA==
 =CYER
 -----END PGP SIGNATURE-----

Merge tag 'pwm/for-6.17-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux

Pull pwm fixes from Uwe Kleine-König:
 "Two fixes for the mediatek and the imx-tpm driver. Both are old
  (v4.12-rc1 and v5.2-rc1 respectively).

  The mediatek issue is that both period and duty_cycle were configured
  to higher values than requested. For most applications the period part
  is no tragedy, but a PWM that is configured for duty_cycle = 0 should
  really emit a constant inactive signal. That was noticed by an LED not
  being completely off in this case (two commits for one fix: a
  preparatory one and the actual fix in the second one).

  For the imx-tpm PWM driver the fixed issue is that the first period is
  quite a bit too long under some circumstances. So it might take up to
  UINT32_MAX << 7 clock ticks until the PWM starts toggling. With an
  assumed input clock rate of 166 MHz (completely made up) that's 55
  minutes"

* tag 'pwm/for-6.17-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux:
  pwm: imx-tpm: Reset counter if CMOD is 0
  pwm: mediatek: Fix duty and period setting
  pwm: mediatek: Handle hardware enable and clock enable separately
2025-07-31 13:27:00 -07:00
Laurentiu Mihalcea
65c6f742ab pwm: imx-tpm: Reset counter if CMOD is 0
As per the i.MX93 TRM, section 67.3.2.1 "MOD register update", the value
of the TPM counter does NOT get updated when writing MOD.MOD unless
SC.CMOD != 0. Therefore, with the current code, assuming the following
sequence:

	1) pwm_disable()
	2) pwm_apply_might_sleep() /* period is changed here */
	3) pwm_enable()

and assuming only one channel is active, if CNT.COUNT is higher than the
MOD.MOD value written during the pwm_apply_might_sleep() call then, when
re-enabling the PWM during pwm_enable(), the counter will end up resetting
after UINT32_MAX - CNT.COUNT + MOD.MOD cycles instead of MOD.MOD cycles as
normally expected.

Fix this problem by forcing a reset of the TPM counter before MOD.MOD is
written.

Fixes: 738a1cfec2 ("pwm: Add i.MX TPM PWM driver support")
Cc: stable@vger.kernel.org
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
Link: https://lore.kernel.org/r/20250728194144.22884-1-laurentiumihalcea111@gmail.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-29 17:51:27 +02:00
Uwe Kleine-König
f21d136caf pwm: mediatek: Fix duty and period setting
The period generated by the hardware is

	(PWMDWIDTH + 1) << CLKDIV) / freq

according to my tests with a signal analyser and also the documentation.

The current algorithm doesn't consider the `+ 1` part and so configures
slightly too high periods. The same issue exists for the duty cycle
setting. So subtract 1 from both the register values for period and
duty cycle. If period is 0, bail out, if duty_cycle is 0, just disable
the PWM which results in a constant low output.

Fixes: caf065f8fd ("pwm: Add MediaTek PWM support")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/6d1fa87a76f8020bfe3171529b8e19baffceab10.1753717973.git.u.kleine-koenig@baylibre.com
Cc: stable@vger.kernel.org
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-29 17:46:29 +02:00
Uwe Kleine-König
704d918341 pwm: mediatek: Handle hardware enable and clock enable separately
Stop handling the clocks in pwm_mediatek_enable() and
pwm_mediatek_disable(). This is a preparing change for the next commit
that requires that clocks and the enable bit are handled separately.

Also move these two functions a bit further up in the source file to
make them usable in pwm_mediatek_config(), which is needed in the next
commit, too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/55c94fe2917ece152ee1e998f4675642a7716f13.1753717973.git.u.kleine-koenig@baylibre.com
Cc: stable@vger.kernel.org
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-29 17:46:18 +02:00
Linus Torvalds
f38b751290 pwm: Changes for v6.17-rc1
Apart from the usual mix of new drivers (pwm-argon-fan-hat), adding
 support for variants to existing drivers, minor improvements to both
 drivers and docs, device tree documenation updates, the noteworthy
 changes are:
 
  - A pull of pm-runtime-6.17-rc1 to make it possible to apply
    a582469541 ("pwm: img: Remove redundant pm_runtime_mark_last_busy()
    calls"). Note this updates the base for my tree to 6.16-rc2.
 
  - A hwmon companion driver to pwm-mc33xs2410 living in drivers/hwmon
    and acked by Guenter Roeck
 
  - chardev support for PWM devices
    This leverages atomic PWM updates to userspace and at the same time
    simplifies and accelerates PWM configuration changes.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmiHQoMACgkQj4D7WH0S
 /k4vGgf+P74bLox7nuZH3lE+D9+HIsfNafELW3TdbmaOF4/iTWOs5/8tUqig3Joc
 b82BHjiuxC0mlHYFC0JcCdW29SKjFUWwZMkB4p0R1vICmQ9MVGC89ABvkTx6mVuF
 Cse8vuQcRXMqt/oo9tcqsJbJmvpLCV+AlD4rdFDTWplVNmrEX2kG5qmdiUmMjjMW
 QNpOxUvdQcKYwrrQjQlEMc+4VmlUN7yDhaw04FzAXg9PPuFfoJEN51PJRdZKDRzP
 ScdViYj3tSpQAXb/mJGKWR5brJw+d4BRzFk3kJR5Sj1WAYSQNpKyhAEGXOX6YteT
 4eehd1xeUG9a8rBctV3CP+38RxcNew==
 =KEjP
 -----END PGP SIGNATURE-----

Merge tag 'pwm/for-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux

Pull pwm updates from Uwe Kleine-König:
 "Apart from the usual mix of new drivers (pwm-argon-fan-hat), adding
  support for variants to existing drivers, minor improvements to both
  drivers and docs, device tree documenation updates, the noteworthy
  changes are:

   - A hwmon companion driver to pwm-mc33xs2410 living in drivers/hwmon
     and acked by Guenter Roeck

   - chardev support for PWM devices. This leverages atomic PWM updates
     to userspace and at the same time simplifies and accelerates PWM
     configuration changes"

* tag 'pwm/for-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux: (35 commits)
  pwm: raspberrypi-poe: Fix spelling mistake "Firwmware" -> "Firmware"
  hwmon: add support for MC33XS2410 hardware monitoring
  pwm: mc33xs2410: add hwmon support
  pwm: img: Remove redundant pm_runtime_mark_last_busy() calls
  pwm: Expose PWM_WFHWSIZE in public header
  dt-bindings: pwm: Convert lpc32xx-pwm.txt to yaml format
  docs: pwm: Adapt Locking paragraph to reality
  pwm: twl-led: Drop driver local locking
  pwm: sun4i: Drop driver local locking
  pwm: sti: Drop driver local locking
  pwm: microchip-core: Drop driver local locking
  pwm: lpc18xx-sct: Drop driver local locking
  pwm: fsl-ftm: Drop driver local locking
  pwm: clps711x: Drop driver local locking
  pwm: atmel: Drop driver local locking
  pwm: argon-fan-hat: Add Argon40 Fan HAT support
  dt-bindings: pwm: argon40,fan-hat: Document Argon40 Fan HAT
  dt-bindings: vendor-prefixes: Document Argon40
  pwm: pwm-mediatek: Add support for PWM IP V3.0.2 in MT6991/MT8196
  pwm: pwm-mediatek: Pass PWM_CK_26M_SEL from platform data
  ...
2025-07-28 23:17:46 -07:00
Linus Torvalds
fcb117e075 gpio updates for v6.17-rc1
GPIOLIB core:
 - introduce a parallel, limited sysfs user ABI that doesn't expose the
   global GPIO numbers to user-space while maintaining backward
   compatibility with the end goal of it completely replacing the existing
   interface, allowing us to remove it
 - remove the legacy devm_gpio_request() routine which has no more users
 - start the process of allowing to compile-out the legacy parts of the
   GPIO core for users who don't need it by introducing a new Kconfig
   option: GPIOLIB_LEGACY
 - don't use global GPIO numbers in debugfs output from the core code
   (drivers still do it, the work is ongoing)
 - start the process of moving the fields specific to the gpio-mmio helper
   out of the core struct gpio_chip into their own structure that wraps
   it: create a new header with modern interfaces and convert several
   drivers to using it
 - remove the platform data structure associated with the gpio-mmio helper
   from the kernel after having converted all remaining users to generic
   device properties
 - remove legacy struct gpio definition as it has no more users
 
 New drivers:
 - add the GPIO driver for the Apple System Management Controller
 
 Driver improvements:
 - add support for new models to gpio-adp5585, gpio-tps65219 and
   gpio-pca953x
 - extend the interrupt support in gpio-loongson-64bit
 - allow to mark the simulated GPIO lines as invalid in gpio-sim
 - convert all remaining GPIO drivers to using the new GPIO value setter
   callbacks
 - convert gpio-rcar to using simple device power management ops callbacks
 - don't check if current direction of a line is output before setting
   the value in gpio-pisosr and ti-fpc202: the GPIO core already handles
   that
 - also drop unneeded GPIO range checks in drivers, the core already makes
   sure we're within bounds when calling driver callbacks
 - use dev_fwnode() where applicable across GPIO drivers
 - set line value in gpio-zynqmp-modepin and gpio-twl6040 when the user
   wants to change direction of the pin to output even though these
   drivers don't need to do anything else to actually set the direction,
   otherwise a call like gpiod_direction_output(d, 1) will not result in
   the line driver high
 - remove the reduntant call to pm_runtime_mark_last_busy() from
   gpio-arizona
 - use lock guards in gpio-cadence and gpio-mxc
 - check the return values of regmap functions in gpio-wcd934x and
   gpio-tps65912
 - use better regmap interfaces in gpio-wcove and gpio-pca953x
 - remove dummy GPIO chip callbacks from several drivers in cases where
   the GPIO core can already handle their absence
 - allow building gpio-palmas as a module
 
 Fixes:
 - use correct bit widths (according to the documentation) in gpio-virtio
 
 Device-tree bindings:
 - convert several of the legacy .txt documents for many different devices
   to YAML, improving automatic validation
 - create a "trivial" GPIO DT schema that covers a wide range of simple
   hardware that share a set of basic GPIO properties
 - document new HW: Apple MAC SMC GPIO block and adp5589 I/O expander
 - document a new model for pca95xx
 - add and/or remove properties in YAML documents for gpio-rockchip,
   fsl,qoriq-gpio, arm,pl061 and gpio-xilinx
 
 Misc:
 - some minor refactoring in several places, adding/removing forward
   declarations, moving defines to better places, constify the arguments
   in some functions, remove duplicate includes, etc.
 - documentation updates
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAmiHQsUACgkQEacuoBRx
 13LNDxAAsHxVqBjdCSzmnOCteIRrRWv8yCzeuPzFWekxGPJNEx/tC83cqdLF2yN/
 MFrlQLx4ZksCBWOmcoC9aQE5c8ZXfnugF2rztxeDIRtSwC0ED97K9Z798RrgLJUF
 M6HyaWgsEcMBDk0jXG2w3JESnPbx74VnGtPixv8+QeiM2DA5XRsLPaPbQEkatBVo
 9T7Ls/vfS6AK9fSqMg2ZjKi3bXpXMsmU4PXrhh/mCGSBU/TO3fF1IPig5SsKUpNL
 C2nm3e4XIaXCNIBqgGSpppbzCrwDBlDTb029QtoStXgsiMbppXI532NjuCfDlj80
 1Vlmwot4O91SJoC9XvmSM6KBWrBqX2zL3bYtpkLymEPPS8+25gwQ3HxteIzl1V4S
 Up8KZ+9EmNxxhfKYzhdWG0Puyam4sHiP1MlkeyEKgHJen4/07Pg4WdOthyuH72tg
 /U5wS+zDhhDpibHFYdQ5F04ubMfVxipvf0JHhbjuDAuXKqGohjJNUiE2/M7yBnyd
 n0IS9Bw95lOLepbAHkm/JneFvSJYJfOrLz+d981664tfrY7A99RLtSOluzQKSrzz
 dpqc+yn+x/TKaZeYV22mhIri5o9oupT7JqPHqXYe//iWzJt3m2EavzTRoR2JeJQq
 p7Quytgfj4FcR2v6GyldXWwFhRK0397kOLcNUQ7HVMaOAMMi5Y8=
 =tUPm
 -----END PGP SIGNATURE-----

Merge tag 'gpio-updates-for-v6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio updates from Bartosz Golaszewski:
 "There's one new driver (Apple SMC) and extensions to existing drivers
  for supporting new HW models. A lot of different impovements across
  drivers and in core GPIO code. Details on that are in the signed tag
  as usual.

  We managed to remove some of the legacy APIs. Arnd Bergmann started to
  work on making the legacy bits optional so that we may compile them
  only for older platforms that still really need them.

  Rob Herring has done a lot of work to convert legacy .txt dt-bindings
  for GPIO controllers to YAML. There are only a few left now in the
  GPIO tree.

  A big part of the commits in this PR concern the conversion of GPIO
  drivers to using the new line value setter callbacks. This conversion
  is now complete treewide (unless I've missed something) and once all
  the changes from different trees land in mainline, I'll send you
  another PR containing a commit dropping the legacy callbacks from the
  tree.

  As the quest to pay back technical dept never really ends, we're
  starting another set of interface conversions, this time it's about
  moving fields specific to only a handful of drivers using the
  gpio-mmio helper out of the core gpio_chip structure that every
  controller implements and uses. This cycle we introduce a new set of
  APIs and convert a few drivers under drivers/gpio/, next cycle we'll
  convert remaining modules treewide (in gpio, pinctrl and mfd trees)
  and finally remove the old interfaces and move the gpio-mmio fields
  into their own structure wrapping gpio_chip.

  One last change I should mention here is the rework of the sysfs
  interface. In 2016, we introduced the GPIO character device as the
  preferred alternative to the sysfs class under /sys/class/gpio. While
  it has seen a wide adoption with the help of its user-space
  counterpart - libgpiod - there are still users who prefer the
  simplicity of sysfs.

  As far as the GPIO subsystem is concerned, the problem is not the
  existince of the GPIO class as such but rather the fact that it
  exposes the global GPIO numbers to the user-space, stopping us from
  ever being able to remove the numberspace from the kernel. To that
  end, this release we introduced a parallel, limited sysfs interface
  that doesn't expose these numbers and only implements a subset of
  features that are relevant to the existing users. This is a result of
  several discussions over the course of last year and should allow us
  to remove the legacy part some time in the future.

  Summary:

  GPIOLIB core:
   - introduce a parallel, limited sysfs user ABI that doesn't expose
     the global GPIO numbers to user-space while maintaining backward
     compatibility with the end goal of it completely replacing the
     existing interface, allowing us to remove it
   - remove the legacy devm_gpio_request() routine which has no more
     users
   - start the process of allowing to compile-out the legacy parts of
     the GPIO core for users who don't need it by introducing a new
     Kconfig option: GPIOLIB_LEGACY
   - don't use global GPIO numbers in debugfs output from the core code
     (drivers still do it, the work is ongoing)
   - start the process of moving the fields specific to the gpio-mmio
     helper out of the core struct gpio_chip into their own structure
     that wraps it: create a new header with modern interfaces and
     convert several drivers to using it
   - remove the platform data structure associated with the gpio-mmio
     helper from the kernel after having converted all remaining users
     to generic device properties
   - remove legacy struct gpio definition as it has no more users

  New drivers:
   - add the GPIO driver for the Apple System Management Controller

  Driver improvements:
   - add support for new models to gpio-adp5585, gpio-tps65219 and
     gpio-pca953x
   - extend the interrupt support in gpio-loongson-64bit
   - allow to mark the simulated GPIO lines as invalid in gpio-sim
   - convert all remaining GPIO drivers to using the new GPIO value
     setter callbacks
   - convert gpio-rcar to using simple device power management ops
     callbacks
   - don't check if current direction of a line is output before setting
     the value in gpio-pisosr and ti-fpc202: the GPIO core already
     handles that
   - also drop unneeded GPIO range checks in drivers, the core already
     makes sure we're within bounds when calling driver callbacks
   - use dev_fwnode() where applicable across GPIO drivers
   - set line value in gpio-zynqmp-modepin and gpio-twl6040 when the
     user wants to change direction of the pin to output even though
     these drivers don't need to do anything else to actually set the
     direction, otherwise a call like gpiod_direction_output(d, 1) will
     not result in the line driver high
   - remove the reduntant call to pm_runtime_mark_last_busy() from
     gpio-arizona
   - use lock guards in gpio-cadence and gpio-mxc
   - check the return values of regmap functions in gpio-wcd934x and
     gpio-tps65912
   - use better regmap interfaces in gpio-wcove and gpio-pca953x
   - remove dummy GPIO chip callbacks from several drivers in cases
     where the GPIO core can already handle their absence
   - allow building gpio-palmas as a module

  Fixes:
   - use correct bit widths (according to the documentation) in
     gpio-virtio

  Device-tree bindings:
   - convert several of the legacy .txt documents for many different
     devices to YAML, improving automatic validation
   - create a "trivial" GPIO DT schema that covers a wide range of
     simple hardware that share a set of basic GPIO properties
   - document new HW: Apple MAC SMC GPIO block and adp5589 I/O expander
   - document a new model for pca95xx
   - add and/or remove properties in YAML documents for gpio-rockchip,
     fsl,qoriq-gpio, arm,pl061 and gpio-xilinx

  Misc:
   - some minor refactoring in several places, adding/removing forward
     declarations, moving defines to better places, constify the
     arguments in some functions, remove duplicate includes, etc.
   - documentation updates"

* tag 'gpio-updates-for-v6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (202 commits)
  MIPS: alchemy: gpio: use new GPIO line value setter callbacks for the remaining chips
  gpiolib: enable CONFIG_GPIOLIB_LEGACY even for !GPIOLIB
  gpio: virtio: Fix config space reading.
  gpiolib: make legacy interfaces optional
  dt-bindings: gpio: rockchip: Allow use of a power-domain
  gpiolib: of: add forward declaration for struct device_node
  power: reset: macsmc-reboot: Add driver for rebooting via Apple SMC
  gpio: Add new gpio-macsmc driver for Apple Macs
  mfd: Add Apple Silicon System Management Controller
  soc: apple: rtkit: Make shmem_destroy optional
  dt-bindings: mfd: Add Apple Mac System Management Controller
  dt-bindings: power: reboot: Add Apple Mac SMC Reboot Controller
  dt-bindings: gpio: Add Apple Mac SMC GPIO block
  gpio: cadence: Remove duplicated include in gpio-cadence.c
  gpio: tps65219: Add support for TI TPS65214 PMIC
  gpio: tps65219: Update _IDX & _OFFSET macro prefix
  gpio: sysfs: Fix an end of loop test in gpiod_unexport()
  dt-bindings: gpio: Convert qca,ar7100-gpio to DT schema
  dt-bindings: gpio: Convert maxim,max3191x to DT schema
  dt-bindings: gpio: fsl,qoriq-gpio: Add missing mpc8xxx compatibles
  ...
2025-07-28 21:58:46 -07:00
Colin Ian King
68b9272ca7 pwm: raspberrypi-poe: Fix spelling mistake "Firwmware" -> "Firmware"
There is a spelling mistake in the PWM_RASPBERRYPI_POE Kconfig,
fix it.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20250724104148.139559-1-colin.i.king@gmail.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-24 23:04:16 +02:00
Dimitri Fedrau
28517c8b62 pwm: mc33xs2410: add hwmon support
Support for hwmon is provided by a separate driver residing in hwmon
subsystem which is implemented as auxiliary device. Add handling of this
device.

Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Link: https://lore.kernel.org/r/20250723-mc33xs2410-hwmon-v5-1-f62aab71cd59@liebherr.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-24 09:20:39 +02:00
Sakari Ailus
a582469541 pwm: img: Remove redundant pm_runtime_mark_last_busy() calls
pm_runtime_put_autosuspend(), pm_runtime_put_sync_autosuspend(),
pm_runtime_autosuspend() and pm_request_autosuspend() now include a call
to pm_runtime_mark_last_busy(). Remove the now-reduntant explicit call to
pm_runtime_mark_last_busy().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://lore.kernel.org/r/20250704075443.3221370-1-sakari.ailus@linux.intel.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-09 10:51:20 +02:00
Michal Wilczynski
edd3bcb180 pwm: Expose PWM_WFHWSIZE in public header
The WFHWSIZE constant defines the maximum size for the hardware-specific
waveform representation buffer. It is currently local to
drivers/pwm/core.c, which makes it inaccessible to external tools like
bindgen.

Move the constant to include/linux/pwm.h to make it part of the public
API. As part of this change, rename it to PWM_WFHWSIZE to follow
standard kernel conventions for namespacing macros in public headers.

This allows bindgen to automatically generate a corresponding constant
for the Rust PWM abstractions, ensuring the value remains synchronized
between the C core and Rust code and preventing future maintenance
issues.

Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
Link: https://lore.kernel.org/r/20250702-rust-next-pwm-working-fan-for-sending-v7-1-67ef39ff1d29@samsung.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:36 +02:00
Uwe Kleine-König
2c06a21789 pwm: twl-led: Drop driver local locking
The pwm core already serializes .apply(). twl6030's .request() and .free()
are also already serialized against .apply() because there is only a single
PWM. So the mutex doesn't add any additional protection and can be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/c1c7f646190f7cb2fe43b10959aa8dade80cb79e.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:36 +02:00
Uwe Kleine-König
dce0df8ac1 pwm: sun4i: Drop driver local locking
The pwm core serializes calls to .apply(), so the driver lock doesn't
add any protection and can safely be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/87b71c46b82b787959f0cea314d3010f16a50a29.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:36 +02:00
Uwe Kleine-König
d2c8bdc72f pwm: sti: Drop driver local locking
The pwm core already serializes calls to .apply(), so the driver local
mutex adds no protection and can be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/7ad150e40b45d6cb16fee633dcd6390a49a327a1.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:36 +02:00
Uwe Kleine-König
9470e7d11f pwm: microchip-core: Drop driver local locking
The pwm core already serializes .apply() and .get_state(), so the driver
local lock is always free and adds no protection.

Drop it.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/6d6ef0376ea0058b040eec3b257e324493a083f1.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:36 +02:00
Uwe Kleine-König
33d73bde06 pwm: lpc18xx-sct: Drop driver local locking
Both mutexes are only used in one function each. These functions are only
called by the .apply() callback. As the .apply() calls are serialized by
the core since commit 1cc2e1faaf ("pwm: Add more locking") the mutexes
have no effect apart from runtime overhead. Drop them.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
Link: https://lore.kernel.org/r/4f7a2da37adbfe4743564245119045826d86eca6.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:36 +02:00
Uwe Kleine-König
7c1a529a24 pwm: fsl-ftm: Drop driver local locking
The pwm core serializes calls to .apply(), so the driver local lock isn't
needed for that. It only has the effect to serialize .apply() with
.request() and .free() for a different PWM, and .request() and .free
against each other. But given that .request and .free() only do a single
regmap operation under the lock and regmap itself serializes register
accesses, it might happen without the lock that the calls are interleaved
now, but affecting different PWMs, so nothing bad can happen.

So the mutex has no effect and can be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/6b72104e5e1823170c7c9664189cc0f2ca5c2347.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:36 +02:00
Uwe Kleine-König
f0d91b16dc pwm: clps711x: Drop driver local locking
The pwm core serializes calls to .apply(), so the spinlock adds no
additional protection. Disabling the irq is also irrelevant as the driver
isn't an atomic one and so the callbacks cannot be called from atomic
context.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/d4931dc0c0d657d80722cfe7d97cb4fb4ccec90e.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:35 +02:00
Uwe Kleine-König
62df49917e pwm: atmel: Drop driver local locking
The two functions making use of the lock are only called transitively from
.apply(). Calls to .apply() are already serialized by the pwm core so the
lock in the driver has no effect and can safely be dropped.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/5ad3417aecd4dc6eca9699e21691e3725ea0bb87.1750788649.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:35 +02:00
Marek Vasut
0191c80e8a pwm: argon-fan-hat: Add Argon40 Fan HAT support
Add trivial PWM driver for Argon40 Fan HAT, which is a RaspberryPi
blower fan hat which can be controlled over I2C. Model this device
as a PWM, so the pwm-fan can be attached to it and handle thermal
zones and RPM management in a generic manner.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Link: https://lore.kernel.org/r/20250629220757.936212-3-marek.vasut+renesas@mailbox.org
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:35 +02:00
AngeloGioacchino Del Regno
e47026facf pwm: pwm-mediatek: Add support for PWM IP V3.0.2 in MT6991/MT8196
Add support for the PWM IP version 3.0.2, found in MediaTek's
Dimensity 9400 MT6991 and in the MT8196 Chromebook SoC: this
needs a new register offset array and also a different offset
for the PWM_CK_26M_SEL register.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20250623120118.109170-4-angelogioacchino.delregno@collabora.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:35 +02:00
AngeloGioacchino Del Regno
d4f1e7a2fe pwm: pwm-mediatek: Pass PWM_CK_26M_SEL from platform data
In preparation for adding support for new SoCs, remove variable
has_ck_26m_sel from pwm_mediatek_of_data and replace it with a
u16 pwm_ck_26m_sel_reg, meant to hold the register offset for
PWM_CK_26M_SEL.

Also, since the reg offset is guaranteed to never be zero, the
logic to check for "has_ck_26m_sel" is changed to check if the
register offset in pwm_ck_26m_sel_reg is more than zero.

Analogously, when writing, use the register offset from platform
data instead of using the PWM_CK_26M_SEL definition.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20250623120118.109170-3-angelogioacchino.delregno@collabora.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:35 +02:00
Nicolas Frattaroli
0b4d1abe5c pwm: rockchip: Round period/duty down on apply, up on get
With CONFIG_PWM_DEBUG=y, the rockchip PWM driver produces warnings like
this:

  rockchip-pwm fd8b0010.pwm: .apply is supposed to round down
  duty_cycle (requested: 23529/50000, applied: 23542/50000)

This is because the driver chooses ROUND_CLOSEST for purported
idempotency reasons. However, it's possible to keep idempotency while
always rounding down in .apply().

Do this by making .get_state() always round up, and making .apply()
always round down. This is done with u64 maths, and setting both period
and duty to U32_MAX (the biggest the hardware can support) if they would
exceed their 32 bits confines.

Fixes: 12f9ce4a51 ("pwm: rockchip: Fix period and duty cycle approximation")
Fixes: 1ebb74cf35 ("pwm: rockchip: Add support for hardware readout")
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Link: https://lore.kernel.org/r/20250616-rockchip-pwm-rounding-fix-v2-1-a9c65acad7b6@collabora.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:35 +02:00
Fabrice Gasnier
fd0b06972a pwm: stm32: add support for stm32mp25
Add support for STM32MP25 SoC. Use newly introduced compatible to handle
new features along with registers and bits diversity.
The MFD part of the driver fills in ipidr, so it is used to check the
hardware configuration register, when available to gather the number
of PWM channels and complementary outputs.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Link: https://lore.kernel.org/r/20250110091922.980627-5-fabrice.gasnier@foss.st.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:34 +02:00
Longbin Li
21d5daad93 pwm: sophgo-sg2042: Add support for SG2044
Add PWM controller for SG2044 on base of SG2042.

Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
Tested-by: Chen Wang <unicorn_wang@outlook.com>
Signed-off-by: Longbin Li <looong.bin@gmail.com>
Link: https://lore.kernel.org/r/20250528101139.28702-4-looong.bin@gmail.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:34 +02:00
Longbin Li
8c805dfafd pwm: sophgo-sg2042: Reorganize the code structure
As the driver logic can be used in both SG2042 and SG2044, it
will be better to reorganize the code structure.

Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
Tested-by: Chen Wang <unicorn_wang@outlook.com>
Signed-off-by: Longbin Li <looong.bin@gmail.com>
Link: https://lore.kernel.org/r/20250528101139.28702-3-looong.bin@gmail.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:34 +02:00
Nylon Chen
6df3aac763 pwm: sifive: Fix rounding and idempotency issues in apply and get_state
This fix ensures consistent rounding and avoids mismatches
between applied and reported PWM values that could trigger false
idempotency failures in debug checks

This change ensures:
- real_period is now calculated using DIV_ROUND_UP_ULL() to avoid underestimation.
- duty_cycle is rounded up to match the fractional computation in apply()
- apply() truncates the result to compensate for get_state's rounding up logic

These fixes resolve issues like:
.apply is supposed to round down duty_cycle (requested: 360/504000, applied: 361/504124)
.apply is not idempotent (ena=1 pol=0 1739692/4032985) -> (ena=1 pol=0 1739630/4032985)

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202505080303.dBfU5YMS-lkp@intel.com/
Co-developed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
Link: https://lore.kernel.org/r/20250529035341.51736-4-nylon.chen@sifive.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:34 +02:00
Nylon Chen
7dbc4432ea pwm: sifive: Fix PWM algorithm and clarify inverted compare behavior
The `frac` variable represents the pulse inactive time, and the result
of this algorithm is the pulse active time. Therefore, we must reverse
the result.

Although the SiFive Reference Manual states "pwms >= pwmcmpX -> HIGH",
the hardware behavior is inverted due to a fixed XNOR with 0. As a result,
the pwmcmp register actually defines the low (inactive) portion of the pulse.

The reference is SiFive FU740-C000 Manual[0]

Link: https://sifive.cdn.prismic.io/sifive/1a82e600-1f93-4f41-b2d8-86ed8b16acba_fu740-c000-manual-v1p6.pdf [0]

Co-developed-by: Zong Li <zong.li@sifive.com>
Signed-off-by: Zong Li <zong.li@sifive.com>
Co-developed-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
Signed-off-by: Nylon Chen <nylon.chen@sifive.com>
Link: https://lore.kernel.org/r/20250529035341.51736-3-nylon.chen@sifive.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:34 +02:00
Guodong Xu
27b5dfe4b4 pwm: pxa: Allow to enable for SpacemiT K1 SoC
The SpacemiT K1 SoC uses devices similar to the ones on PXA SoCs. Add
ARCH_SPACEMIT as one of the possible architectures this driver can be
enabled for.

Signed-off-by: Guodong Xu <guodong@riscstar.com>
Link: https://lore.kernel.org/r/20250429085048.1310409-6-guodong@riscstar.com
[ukleinek: reword commit log]
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:34 +02:00
Guodong Xu
52d2d14d9e pwm: pxa: Add optional reset control
Support optional reset control for the PWM PXA driver.

During probe, it acquires the reset controller using
devm_reset_control_get_optional_exclusive_deasserted() to get and deassert
the reset controller to enable the PWM channel.

Signed-off-by: Guodong Xu <guodong@riscstar.com>
Link: https://lore.kernel.org/r/20250429085048.1310409-3-guodong@riscstar.com
[ukleinek: Fix conflict with commit df08fff8ad ("pwm: pxa: Improve using dev_err_probe()")]
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:33 +02:00
Uwe Kleine-König
9c06f26ba5 pwm: Add support for pwmchip devices for faster and easier userspace access
With this change each pwmchip defining the new-style waveform callbacks
can be accessed from userspace via a character device. Compared to the
sysfs-API this is faster and allows to pass the whole configuration in a
single ioctl allowing atomic application and thus reducing glitches.

On an STM32MP13 I see:

	root@DistroKit:~ time pwmtestperf
	real	0m 1.27s
	user	0m 0.02s
	sys	0m 1.21s
	root@DistroKit:~ rm /dev/pwmchip0
	root@DistroKit:~ time pwmtestperf
	real	0m 3.61s
	user	0m 0.27s
	sys	0m 3.26s

pwmtestperf does essentially:

	for i in 0 .. 50000:
		pwm_set_waveform(duty_length_ns=i, period_length_ns=50000, duty_offset_ns=0)

and in the presence of /dev/pwmchip0 is uses the ioctls introduced here,
without that device it uses /sys/class/pwm/pwmchip0.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/ad4a4e49ae3f8ea81e23cac1ac12b338c3bf5c5b.1746010245.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:39:33 +02:00
Uwe Kleine-König
505b730ede pwm: mediatek: Ensure to disable clocks in error path
After enabling the clocks each error path must disable the clocks again.
One of them failed to do so. Unify the error paths to use goto to make it
harder for future changes to add a similar bug.

Fixes: 7ca59947b5 ("pwm: mediatek: Prevent divide-by-zero in pwm_mediatek_config()")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20250704172728.626815-2-u.kleine-koenig@baylibre.com
Cc: stable@vger.kernel.org
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:34:44 +02:00
Uwe Kleine-König
9ee124caae pwm: Fix invalid state detection
Commit 9dd42d019e ("pwm: Allow pwm state transitions from an invalid
state") intended to allow some state transitions that were not allowed
before. The idea is sane and back then I also got the code comment
right, but the check for enabled is bogus. This resulted in state
transitions for enabled states to be allowed to have invalid duty/period
settings and thus it can happen that low-level drivers get requests for
invalid states🙄.

Invert the check to allow state transitions for disabled states only.

Fixes: 9dd42d019e ("pwm: Allow pwm state transitions from an invalid state")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20250704172416.626433-2-u.kleine-koenig@baylibre.com
Cc: stable@vger.kernel.org
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-07-07 08:33:44 +02:00
Nuno Sá
75024f97e8 pwm: adp5585: add support for adp5589
Add support for the adp5589 I/O expander. From a PWM point of view it is
pretty similar to adp5585. Main difference is the address
of registers meaningful for configuring the PWM.

Acked-by: Uwe Kleine-König <ukleinek@kernel.org>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20250701-dev-adp5589-fw-v7-10-b1fcfe9e9826@analog.com
Signed-off-by: Lee Jones <lee@kernel.org>
2025-07-01 21:50:51 +01:00
Nuno Sá
e551760164 mfd: adp5585: Enable oscillator during probe
Make sure to enable the oscillator in the top device. This will allow to
not control this in the child PWM device as that would not work with
future support for keyboard matrix where the oscillator needs to be
always enabled (and so cannot be disabled by disabling PWM).

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Acked-by: Uwe Kleine-König <ukleinek@kernel.org>
Link: https://lore.kernel.org/r/20250701-dev-adp5589-fw-v7-3-b1fcfe9e9826@analog.com
Signed-off-by: Lee Jones <lee@kernel.org>
2025-07-01 21:50:50 +01:00
Nuno Sá
2ad26b7bed
include: linux: move adi-axi-common.h out of fpga
The adi-axi-common.h header has some common defines used in various ADI
IPs. However they are not specific for any fpga manager so it's
questionable for the header to live under include/linux/fpga. Hence
let's just move one directory up and update all users.

Suggested-by: Xu Yilun <yilun.xu@linux.intel.com>
Acked-by: Xu Yilun <yilun.xu@intel.com>
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for IIO
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20250519-dev-axi-clkgen-limits-v6-3-bc4b3b61d1d4@analog.com
Acked-by: Mark Brown <broonie@kernel.org>
Acked-by: Uwe Kleine-König <ukleinek@kernel.org>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
2025-06-30 17:57:15 -07:00
Linus Torvalds
8a2ba6f8ee pwm: axi-pwmgen: Fix handling of external clock
The pwm-axi-pwmgen device is backed by an FPGA and can be synthesized in
 different ways. Relevant here is that it can use one or two external
 clock signals. The changes included here fix clock handling for the two
 clocks case.
 -----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCgAdFiEEP4GsaTp6HlmJrf7Tj4D7WH0S/k4FAmhCto0ACgkQj4D7WH0S
 /k5EawgAk3EcnDZyL+8VwymzF0xHxDjgNKaf7NDVErqt/kwfDhidDNqb8ABo7mKN
 cn5BeuVzngH00mCQuHzvT8vRu7YMOhbOJHaZmXPaMtGUIEe+rZn7+x2i/cW5aHSU
 nbx+TtzSvQufI13FWF+IbLP+2r+hbEbPLqFKnkVSxIZOBOig1IthpejWvurPdze0
 1k3kvoRoQTN7ic50iCvjR7rqwFgBkpzRDOUyK/JFFocCYqgSEAVV9ykAcocoWNVQ
 ZbxTOQ6erSotlkjLFWTCfsEc4S3CJSCTlgPfTXwh13Gvl+3Gi9x8P3E9UrS0I6fj
 qnVCOuwF3EfOlmIfC4YcDeMBSho8fg==
 =41HV
 -----END PGP SIGNATURE-----

Merge tag 'pwm/for-6.16-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux

Pull pwm fixes from Uwe Kleine-König:
 "axi-pwmgen: Fix handling of external clock

  The pwm-axi-pwmgen device is backed by an FPGA and can be synthesized
  in different ways. Relevant here is that it can use one or two
  external clock signals. These fix clock handling for the two clocks
  case"

* tag 'pwm/for-6.16-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux:
  pwm: axi-pwmgen: fix missing separate external clock
  dt-bindings: pwm: adi,axi-pwmgen: Fix clocks
2025-06-06 13:16:50 -07:00
Linus Torvalds
69352bd52b MFD for v6.16
* Samsung Exynos ACPM:
     * Populate child platform devices from device tree data
     * Introduce a new API, `devm_acpm_get_by_node()`, for child devices to get the ACPM handle
   * ROHM PMICs:
     * Add support for the ROHM BD96802 scalable companion PMIC to the BD96801 core driver
     * Add support for controlling the BD96802 using the BD96801 regulator driver
     * Add support to the BD96805, which is almost identical to the BD96801
     * Add support to the BD96806, which is similar to the BD96802
   * Maxim MAX77759:
     * Add a core driver for the MAX77759 companion PMIC
     * Add a GPIO driver for the expander functions on the MAX77759
     * Add an NVMEM driver to expose the non-volatile memory on the MAX77759
   * STMicroelectronics STM32MP25:
     * Add support for the STM32MP25 SoC to the stm32-lptimer
     * Add support for the STM32MP25 to the clocksource driver, handling new register access requirements
     * Add support for the STM32MP25 to the PWM driver, enabling up to two PWM outputs
   * Broadcom BCM590xx:
     * Add support for the BCM59054 PMU
     * Parse the PMU ID and revision to support behavioral differences between chip revisions
     * Add regulator support for the BCM59054
   * Samsung S2MPG10:
     * Add support for the S2MPG10 PMIC, which communicates via the Samsung ACPM firmware instead of I2C
 
   * Exynos ACPM:
     * Improve timeout detection reliability by using ktime APIs instead of a loop counter assumption
     * Allow PMIC access during late system shutdown by switching to `udelay()` instead of a sleeping function
     * Fix an issue where reading command results longer than 8 bytes would fail
     * Silence non-error `-EPROBE_DEFER` messages during boot to clean up logs
   * Exynos LPASS:
     * Fix an error handling path by switching to `devm_regmap_init_mmio()` to prevent resource leaks
     * Fix a bug where `exynos_lpass_disable()` was called twice in the remove function
     * Fix another resource leak in the probe's error path by using `devm_add_action_or_reset()`
   * Samsung SEC:
     * Handle the s2dos05, which does not have IRQ support, explicitly to prevent warnings
     * Fix the core driver to correctly handle errors from `sec_irq_init()` instead of ignoring them
   * STMPE-SPI:
     * Correct an undeclared identifier in the `MODULE_DEVICE_TABLE` macro
   * MAINTAINERS:
     * Adjust a file path for the Siemens IPC LED drivers entry to fix a broken reference
   * Maxim Drivers:
     * Correct the spelling of "Electronics" in Samsung copyright headers across multiple files
   * General:
     * Fix wakeup source memory leaks on device unbind for 88pm886, as3722, max14577, max77541, max77705,
       max8925, rt5033, and sprd-sc27xx drivers
 
   * Samsung SEC Drivers:
     * Split the driver into a transport-agnostic core (`sec-core`) and transport-specific (`sec-i2c`,
       `sec-acpm`) modules to support non-I2C devices
     * Merge the `sec-core` and `sec-irq` modules to reduce memory consumption
     * Move internal APIs to a private header to clean up the public API
     * Improve code style by sorting includes, cleaning up headers, sorting device tables, and using helper
       macros like `dev_err_probe()`, `MFD_CELL`, and `REGMAP_IRQ_REG`
     * Make regmap configuration for s2dos05/s2mpu05 explicit to improve clarity
     * Rework platform data and regmap instantiation to use OF match data instead of a large switch statement
   * ROHM BD96801/2:
     * Prepare the driver for new models by separating chip-specific data into its own structure
     * Drop IC name prefix from IRQ resource names in both the MFD and regulator drivers for simplification
   * Broadcom BCM590xx:
     * Refactor the regulator driver to store descriptions in a table to ease support for new chips
     * Rename BCM59056-specific data to prepare for the addition of other regulators
     * Use `dev_err_probe()` for cleaner error handling
   * Exynos ACPM:
     * Correct kerneldoc warnings and use the conventional 'np' argument name
   * General MFD:
     * Convert `aat2870` and `tps65010` to use the per-client debugfs directory provided by the I2C core
     * Convert `sm501`, `tps65010` and `ucb1x00` to use the new GPIO line value setter callbacks
     * Constify `regmap_irq_chip` and other structures in `88pm886` to move data to read-only sections
 
   * BCM590xx:
     * Drop the unused "id" member from the `bcm590xx` struct in preparation for a replacement
   * Samsung SEC Core:
     * Remove forward declarations for functions that no longer exist
   * SM501:
     * Remove the unused `sm501_find_clock()` function
 
   * New Compatibles:
     * Google: Add a PMIC child node to the `google,gs101-acpm-ipc` binding
     * ROHM: Add new bindings for `rohm,bd96802-regulator` and `rohm,bd96802-pmic`, and add compatibles
       for BD96805 and BD96806
     * Maxim: Add new bindings for `maxim,max77759-gpio`, `maxim,max77759-nvmem`, and the top-level
       `maxim,max77759`
     * STM: Add `stm32mp25` compatible to the `stm32-lptimer` binding
     * Broadcom: Add `bcm59054` compatible
     * Atmel/Microchip: Add `microchip,sama7d65-gpbr` and `microchip,sama7d65-secumod` compatibles
     * Samsung: Add `s2mpg10` compatible to the `samsung,s2mps11` MFD binding
     * MediaTek: Add compatibles for `mt6893` (scpsys), `mt7988-topmisc`, and `mt8365-infracfg-nao`
     * Qualcomm: Add `qcom,apq8064-mmss-sfpb` and `qcom,apq8064-sps-sic` syscon compatibles
   * Refactoring & Cleanup:
     * Convert Broadcom BCM59056 devicetree bindings to YAML and split them into MFD and regulator parts
     * Convert the Microchip AT91 secumod binding to YAML
     * Drop unrelated consumer nodes from binding examples to reduce bloat
     * Correct indentation and style in various DTS examples
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAmg+xmQACgkQUa+KL4f8
 d2FJAxAApmk3kxAlb9r6E268SY1qQSeQKhhzQZeQz1Dt9ZfMurgnou+EdY5juxCH
 owu4AjyQdaC/eIJJRaBcBjcskmNRsVd7mGwQfhMyg7IvhM9k1PxTuad/PSRauGqy
 p7XnYFYeDa9fwwAZ8qD01gpCenQ3oLm4ef05FGC5SDlqcZzxOzc4iGYgHYjE7ACp
 Iuv5tN0JkxCzTGtpZ6kXn5tp895KcndzPWgS0eQxf6Plw2syF0KKxlVCWUfLjAaZ
 Db1VFOkc2vgjhxuFPpybGzRhgtVKRdYRJqL4EQEhnB/u23cuxxqBSJ3BPGIjfqrA
 h6zaxbYJyBF3cHz9kOqi99inN4T3cZssOSdqIVuWTYSuH+FDdsVi5BF2WlrSgWqn
 hgyVZYjMEB4UbEU+0VdZMqTWjY0+kmAEl7xWQ++sp2cuTtYdcufrldLVl0d/HOCm
 zLXia1A2KHgFoBFN/sP0ffZD9ceM/ng1h1tfz+48MWWO7obpwbdFNtWllblfpm9d
 cYPlg0uddFljjzP/gm3jgJAZkMer2m5eSVfvf2L5VrSROFSfbxwHcvVgRTxmPR0K
 1rQqLm1w2Tp8HCocuO95bRv5g0Z4jWDu+CssM1XZrEXaNCZ5E0qm374JArpAFctb
 cAVFcLYSUT73S6lgBOjF05F2zGPCmqW26S+R2cMPcM2SA1N89Go=
 =hiAm
 -----END PGP SIGNATURE-----

Merge tag 'mfd-next-6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
 "Samsung Exynos ACPM:
   - Populate child platform devices from device tree data
   - Introduce a new API, 'devm_acpm_get_by_node()', for child devices
     to get the ACPM handle

  ROHM PMICs:
   - Add support for the ROHM BD96802 scalable companion PMIC to the
     BD96801 core driver
   - Add support for controlling the BD96802 using the BD96801 regulator
     driver
   - Add support to the BD96805, which is almost identical to the
     BD96801
   - Add support to the BD96806, which is similar to the BD96802

  Maxim MAX77759:
   - Add a core driver for the MAX77759 companion PMIC
   - Add a GPIO driver for the expander functions on the MAX77759
   - Add an NVMEM driver to expose the non-volatile memory on the
     MAX77759

  STMicroelectronics STM32MP25:
   - Add support for the STM32MP25 SoC to the stm32-lptimer
   - Add support for the STM32MP25 to the clocksource driver, handling
     new register access requirements
   - Add support for the STM32MP25 to the PWM driver, enabling up to two
     PWM outputs

  Broadcom BCM590xx:
   - Add support for the BCM59054 PMU
   - Parse the PMU ID and revision to support behavioral differences
     between chip revisions
   - Add regulator support for the BCM59054

  Samsung S2MPG10:
   - Add support for the S2MPG10 PMIC, which communicates via the
     Samsung ACPM firmware instead of I2C

  Exynos ACPM:
   - Improve timeout detection reliability by using ktime APIs instead
     of a loop counter assumption
   - Allow PMIC access during late system shutdown by switching to
     'udelay()' instead of a sleeping function
   - Fix an issue where reading command results longer than 8 bytes
     would fail
   - Silence non-error '-EPROBE_DEFER' messages during boot to clean up
     logs

  Exynos LPASS:
   - Fix an error handling path by switching to
     'devm_regmap_init_mmio()' to prevent resource leaks
   - Fix a bug where 'exynos_lpass_disable()' was called twice in the
     remove function
   - Fix another resource leak in the probe's error path by using
     'devm_add_action_or_reset()'

  Samsung SEC:
   - Handle the s2dos05, which does not have IRQ support, explicitly to
     prevent warnings
   - Fix the core driver to correctly handle errors from
     'sec_irq_init()' instead of ignoring them

  STMPE-SPI:
   - Correct an undeclared identifier in the 'MODULE_DEVICE_TABLE' macro

  MAINTAINERS:
   - Adjust a file path for the Siemens IPC LED drivers entry to fix a
     broken reference

  Maxim Drivers:
   - Correct the spelling of "Electronics" in Samsung copyright headers
     across multiple files

  General:
   - Fix wakeup source memory leaks on device unbind for 88pm886,
     as3722, max14577, max77541, max77705, max8925, rt5033, and
     sprd-sc27xx drivers

  Samsung SEC Drivers:
   - Split the driver into a transport-agnostic core ('sec-core') and
     transport-specific ('sec-i2c', 'sec-acpm') modules to support
     non-I2C devices
   - Merge the 'sec-core' and 'sec-irq' modules to reduce memory
     consumption
   - Move internal APIs to a private header to clean up the public API
   - Improve code style by sorting includes, cleaning up headers,
     sorting device tables, and using helper macros like
     'dev_err_probe()', 'MFD_CELL', and 'REGMAP_IRQ_REG'
   - Make regmap configuration for s2dos05/s2mpu05 explicit to improve
     clarity
   - Rework platform data and regmap instantiation to use OF match data
     instead of a large switch statement

  ROHM BD96801/2:
   - Prepare the driver for new models by separating chip-specific data
     into its own structure
   - Drop IC name prefix from IRQ resource names in both the MFD and
     regulator drivers for simplification

  Broadcom BCM590xx:
   - Refactor the regulator driver to store descriptions in a table to
     ease support for new chips
   - Rename BCM59056-specific data to prepare for the addition of other
     regulators
   - Use 'dev_err_probe()' for cleaner error handling

  Exynos ACPM:
   - Correct kerneldoc warnings and use the conventional 'np' argument
     name

  General MFD:
   - Convert 'aat2870' and 'tps65010' to use the per-client debugfs
     directory provided by the I2C core
   - Convert 'sm501', 'tps65010' and 'ucb1x00' to use the new GPIO line
     value setter callbacks
   - Constify 'regmap_irq_chip' and other structures in '88pm886' to
     move data to read-only sections

  BCM590xx:
   - Drop the unused "id" member from the 'bcm590xx' struct in
     preparation for a replacement

  Samsung SEC Core:
   - Remove forward declarations for functions that no longer exist

  SM501:
   - Remove the unused 'sm501_find_clock()' function

  New Compatibles:
   - Google: Add a PMIC child node to the 'google,gs101-acpm-ipc'
     binding
   - ROHM: Add new bindings for 'rohm,bd96802-regulator' and
     'rohm,bd96802-pmic', and add compatibles for BD96805 and BD96806
   - Maxim: Add new bindings for 'maxim,max77759-gpio',
     'maxim,max77759-nvmem', and the top-level 'maxim,max77759'
   - STM: Add 'stm32mp25' compatible to the 'stm32-lptimer' binding
   - Broadcom: Add 'bcm59054' compatible
   - Atmel/Microchip: Add 'microchip,sama7d65-gpbr' and
     'microchip,sama7d65-secumod' compatibles
   - Samsung: Add 's2mpg10' compatible to the 'samsung,s2mps11' MFD
     binding
   - MediaTek: Add compatibles for 'mt6893' (scpsys), 'mt7988-topmisc',
     and 'mt8365-infracfg-nao'
   - Qualcomm: Add 'qcom,apq8064-mmss-sfpb' and 'qcom,apq8064-sps-sic'
     syscon compatibles

  Refactoring & Cleanup:
   - Convert Broadcom BCM59056 devicetree bindings to YAML and split
     them into MFD and regulator parts
   - Convert the Microchip AT91 secumod binding to YAML
   - Drop unrelated consumer nodes from binding examples to reduce bloat
   - Correct indentation and style in various DTS examples"

* tag 'mfd-next-6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (81 commits)
  mfd: maxim: Correct Samsung "Electronics" spelling in copyright headers
  mfd: maxim: Correct Samsung "Electronics" spelling in headers
  mfd: sm501: Remove unused sm501_find_clock
  mfd: 88pm886: Constify struct regmap_irq_chip and some other structures
  dt-bindings: mfd: syscon: Add mediatek,mt8365-infracfg-nao
  mfd: sprd-sc27xx: Fix wakeup source leaks on device unbind
  mfd: rt5033: Fix wakeup source leaks on device unbind
  mfd: max8925: Fix wakeup source leaks on device unbind
  mfd: max77705: Fix wakeup source leaks on device unbind
  mfd: max77541: Fix wakeup source leaks on device unbind
  mfd: max14577: Fix wakeup source leaks on device unbind
  mfd: as3722: Fix wakeup source leaks on device unbind
  mfd: 88pm886: Fix wakeup source leaks on device unbind
  dt-bindings: mfd: Correct indentation and style in DTS example
  dt-bindings: mfd: Drop unrelated nodes from DTS example
  dt-bindings: mfd: syscon: Add qcom,apq8064-sps-sic
  dt-bindings: mfd: syscon: Add qcom,apq8064-mmss-sfpb
  mfd: stmpe-spi: Correct the name used in MODULE_DEVICE_TABLE
  dt-bindings: mfd: syscon: Add mt7988-topmisc
  mfd: exynos-lpass: Fix another error handling path in exynos_lpass_probe()
  ...
2025-06-03 11:53:55 -07:00
David Lechner
a8841dc3df pwm: axi-pwmgen: fix missing separate external clock
Add proper support for external clock to the AXI PWM generator driver.

In most cases, the HDL for this IP block is compiled with the default
ASYNC_CLK_EN=1. With this option, there is a separate external clock
that drives the PWM output separate from the peripheral clock. So the
driver should be enabling the "axi" clock to power the peripheral and
the "ext" clock to drive the PWM output.

When ASYNC_CLK_EN=0, the "axi" clock is also used to drive the PWM
output and there is no "ext" clock.

Previously, if there was a separate external clock, users had to specify
only the external clock and (incorrectly) omit the AXI clock in order
to get the correct operating frequency for the PWM output.

The devicetree bindings are updated to fix this shortcoming and this
patch changes the driver to match the new bindings. To preserve
compatibility with any existing dtbs that specify only one clock, we
don't require the clock name on the first clock.

Fixes: 41814fe5c7 ("pwm: Add driver for AXI PWM generator")
Cc: stable@vger.kernel.org
Acked-by: Nuno Sá <nuno.sa@analog.com>
Reviewed-by: Trevor Gamblin <tgamblin@baylibre.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://lore.kernel.org/r/20250529-pwm-axi-pwmgen-add-external-clock-v3-3-5d8809a7da91@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-06-02 18:23:33 +02:00
Nuno Sá
9c5e285f60 pwm: adp5585: make sure to include mod_devicetable.h
Explicitly include mod_devicetable.h for struct platform_device_id.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20250512-dev-adp5589-fw-v3-22-092b14b79a88@analog.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-05-19 18:07:39 +02:00
Kuninori Morimoto
25ac4834ca pwm: Tidyup PWM menu for Renesas
Because current PWM Kconfig is sorting by symbol name,
it looks strange ordering in menuconfig.

=>	[ ]   Renesas R-Car PWM support
=>	[ ]   Renesas TPU PWM support
	[ ]   Rockchip PWM support
=>	[ ]   Renesas RZ/G2L General PWM Timer support
=>	[ ]   Renesas RZ/G2L MTU3a PWM Timer support

Let's use common CONFIG_PWM_RENESAS_xxx symbol name for Renesas,
and sort it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/877c2mxrrr.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-05-14 10:20:55 +02:00
Fabrice Gasnier
3f51b232c1 pwm: stm32-lp: Add support for stm32mp25
Add support for STM32MP25 SoC. A new compatible has been added to the
dt-bindings. It represents handle new features, registers and bits
diversity.
It isn't used currently in the driver, as matching is done by retrieving
MFD parent data.

New dedicated capture/compare channels has been added: e.g. a new compare
register for channel 2. Some controls (polarity / cc channel enable) are
handled in CCMR register on this new variant (instead of wavepol bit).

So, Low-power timer can now have up to two PWM outputs. Use device data
from the MFD parent to configure the number of PWM channels e.g. 'npwm'.

Update current get_state() and apply() ops to support either:
- one PWM channel (as on older revision, or LPTIM5 on STM32MP25)
- two PWM channels (e.g. LPTIM1/2/3/4 on STM32MP25 that has the full
  feature set)
Introduce new routines to manage common prescaler, reload register and
global enable bit.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
Acked-by: Uwe Kleine-König <ukleinek@kernel.org>
Link: https://lore.kernel.org/r/20250429125133.1574167-5-fabrice.gasnier@foss.st.com
Signed-off-by: Lee Jones <lee@kernel.org>
2025-05-13 11:13:56 +01:00
Uwe Kleine-König
84e351d8a5 pwm: Restore alphabetic ordering in Kconfig and Makefile
The drivers are nearly ordered alphabetically by the symbol name. Fix the
few outliers.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20250508081706.751209-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-05-08 11:52:31 +02:00
Uwe Kleine-König
d041b76ac9 pwm: Formally describe the procedure used to pick a hardware waveform setting
This serves as specification for both, PWM consumers and the respective
callback for lowlevel drivers.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/d2916bfa70274961ded26b07ab6998c36b90e69a.1746010245.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-05-07 11:48:35 +02:00
Uwe Kleine-König
164c4ac754 pwm: Let pwm_set_waveform_might_sleep() return 0 instead of 1 after rounding up
While telling the caller of pwm_set_waveform_might_sleep() if the
request was completed by rounding down only or (some) rounding up gives
additional information, it makes usage this function needlessly hard and
the additional information is not used. A prove for that is that
currently both users of this function just pass the returned value up to
their caller even though a positive value isn't intended there.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/528cc3bbd9e35dea8646b1bcc0fbfe6c498bb4ed.1746010245.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-05-07 11:48:35 +02:00
Uwe Kleine-König
e866834c8b pwm: Let pwm_set_waveform_might_sleep() fail for exact but impossible requests
Up to now pwm_set_waveform_might_sleep() returned 1 for exact requests
that couldn't be served exactly. In contrast to
pwm_round_waveform_might_sleep() and pwm_set_waveform_might_sleep() with
exact = false this is an error condition. So simplify handling for
callers of pwm_set_waveform_might_sleep() by returning -EDOM instead of
1 in this case.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20538a46719584dafd8a1395c886780a97dcdf79.1746010245.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-05-07 11:48:35 +02:00
Dimitri Fedrau
2006016ec6 pwm: add support for NXPs high-side switch MC33XS2410
The MC33XS2410 is a four channel high-side switch. Featuring advanced
monitoring and control function, the device is operational from 3.0 V to
60 V. The device is controlled by SPI port for configuration.

Signed-off-by: Dimitri Fedrau <dimitri.fedrau@liebherr.com>
Link: https://lore.kernel.org/r/20250407-mc33xs2410-v9-2-57adcb56a6e4@liebherr.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-05-02 18:39:21 +02:00
Uwe Kleine-König
e373991eb9 pwm: rzg2l-gpt: Accept requests for too high period length
The period setting is shared for each pair of PWM channels. So if the
twin channel is in use, the period must not be changed. According to the
usual practise to pick the next smaller possible period, accept a
request for a period that is bigger than the unchangable value.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Tested-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20250423095715.2952692-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-04-30 09:01:03 +02:00
Uwe Kleine-König
7f8ce4d88b pwm: Fix various formatting issues in kernel-doc
Add Return and (where interesting) Context sections, fix some formatting
and drop documenting the internal function __pwm_apply().

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20250417181611.2693599-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-04-24 16:43:54 +02:00
Biju Das
061f087f5d pwm: Add support for RZ/G2L GPT
RZ/G2L General PWM Timer (GPT) composed of 8 channels with 32-bit timer
(GPT32E). It supports the following functions
 * 32 bits x 8 channels
 * Up-counting or down-counting (saw waves) or up/down-counting
   (triangle waves) for each counter.
 * Clock sources independently selectable for each channel
 * Two I/O pins per channel
 * Two output compare/input capture registers per channel
 * For the two output compare/input capture registers of each channel,
   four registers are provided as buffer registers and are capable of
   operating as comparison registers when buffering is not in use.
 * In output compare operation, buffer switching can be at crests or
   troughs, enabling the generation of laterally asymmetric PWM waveforms.
 * Registers for setting up frame cycles in each channel (with capability
   for generating interrupts at overflow or underflow)
 * Generation of dead times in PWM operation
 * Synchronous starting, stopping and clearing counters for arbitrary
   channels
 * Starting, stopping, clearing and up/down counters in response to input
   level comparison
 * Starting, clearing, stopping and up/down counters in response to a
   maximum of four external triggers
 * Output pin disable function by dead time error and detected
   short-circuits between output pins
 * A/D converter start triggers can be generated (GPT32E0 to GPT32E3)
 * Enables the noise filter for input capture and external trigger
   operation

Add basic pwm support for RZ/G2L GPT driver by creating separate
logical channels for each IOs.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20250226144531.176819-4-biju.das.jz@bp.renesas.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
2025-04-17 11:52:13 +02:00