linux/drivers/pwm
Clemens Gruber 01ec847200 pwm-pca9685: Support changing the output frequency
Previously, period_ns and duty_ns were only used to determine the
ratio of ON and OFF time, the default frequency of 200 Hz was never
changed.
The PCA9685 however is capable of changing the PWM output frequency,
which is expected when changing the period.

This patch configures the prescaler accordingly, using the formula
and notes provided in the PCA9685 datasheet.
Bounds checking for the minimum and maximum frequencies, last updated
in revision v.4 of said datasheet, is also added.

The prescaler is only touched if the period changed, because we have to
put the chip into sleep mode to unlock the prescale register.
If it is changed, the PWM output frequency changes for all outputs,
because there is one prescaler per chip. This is documented in the
PCA9685 datasheet and in the comments.

If the duty cycle is not changed at the same time as the period, then
we restart the PWM output using the duty cycle to period ratio from
before the period change.
When using LEDs for example, previously set brightness levels stay the
same when the frequency changes.

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
2015-08-17 16:35:46 +02:00
..
core.c pwm: Clean up kerneldoc 2015-08-17 15:40:20 +02:00
Kconfig pwm: Imagination Technologies PWM DAC driver 2015-01-30 12:16:04 +01:00
Makefile pwm: Imagination Technologies PWM DAC driver 2015-01-30 12:16:04 +01:00
pwm-ab8500.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-atmel-hlcdc.c pwm: atmel-hlcdc: Add errata handling for sama5d4 2015-03-11 11:59:54 +01:00
pwm-atmel-tcb.c pwm: Add the pwm_is_enabled() helper 2015-07-20 09:46:06 +02:00
pwm-atmel.c pwm: Make use of pwm_get_xxx() helpers where appropriate 2015-07-20 09:53:22 +02:00
pwm-bcm2835.c pwm: Add BCM2835 PWM driver 2014-11-17 12:20:13 +01:00
pwm-bcm-kona.c pwm: kona: Modify settings application sequence 2015-08-17 16:19:41 +02:00
pwm-bfin.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-clps711x.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-ep93xx.c pwm: Add the pwm_is_enabled() helper 2015-07-20 09:46:06 +02:00
pwm-fsl-ftm.c pwm: ftm: Add Power Management support for FTM PWM 2014-12-01 10:48:54 +01:00
pwm-img.c pwm: img: Impose upper and lower timebase steps value 2015-05-19 16:07:40 +02:00
pwm-imx.c pwm: Make use of pwm_get_xxx() helpers where appropriate 2015-07-20 09:53:22 +02:00
pwm-jz4740.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-lp3943.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-lpc32xx.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-lpss-pci.c pwm: lpss: pci: Add support for Broxton platform 2015-06-12 12:46:50 +02:00
pwm-lpss-platform.c pwm: lpss: Properly split driver to parts 2014-08-23 00:25:47 +02:00
pwm-lpss.c pwm: lpss: use c99 initializers in structures 2014-08-25 11:45:34 +02:00
pwm-lpss.h pwm: lpss: Properly split driver to parts 2014-08-23 00:25:47 +02:00
pwm-mxs.c pwm: Add the pwm_is_enabled() helper 2015-07-20 09:46:06 +02:00
pwm-pca9685.c pwm-pca9685: Support changing the output frequency 2015-08-17 16:35:46 +02:00
pwm-puv3.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-pxa.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-renesas-tpu.c pwm: Add the pwm_is_enabled() helper 2015-07-20 09:46:06 +02:00
pwm-rockchip.c pwm: Make use of pwm_get_xxx() helpers where appropriate 2015-07-20 09:53:22 +02:00
pwm-samsung.c pwm: samsung: Use MODULE_DEVICE_TABLE() to include OF modalias 2015-05-21 15:56:53 +02:00
pwm-spear.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-sti.c pwm: sti: Maintain a bitmap of configured devices 2015-01-30 12:16:03 +01:00
pwm-sun4i.c pwm: Add Allwinner SoC support 2015-01-30 12:16:01 +01:00
pwm-tegra.c pwm: Add the pwm_is_enabled() helper 2015-07-20 09:46:06 +02:00
pwm-tiecap.c pwm: Add the pwm_is_enabled() helper 2015-07-20 09:46:06 +02:00
pwm-tiehrpwm.c pwm: Add the pwm_is_enabled() helper 2015-07-20 09:46:06 +02:00
pwm-tipwmss.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
pwm-tipwmss.h pwm: davinci: Add Kconfig support for ECAP & EHRPWM devices 2013-03-22 11:35:20 +01:00
pwm-twl-led.c pwm: twl-led: Include linux/of.h header 2013-10-08 15:45:44 +02:00
pwm-twl.c pwm: twl: Really disable twl6030 PWMs 2014-05-08 23:41:47 +02:00
pwm-vt8500.c pwm: drop owner assignment from platform_drivers 2014-10-20 16:21:28 +02:00
sysfs.c pwm: sysfs: Remove unnecessary padding 2015-07-27 12:03:38 +02:00