mirror of
https://github.com/torvalds/linux.git
synced 2024-11-16 00:52:01 +00:00
01ec847200
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> |
||
---|---|---|
.. | ||
core.c | ||
Kconfig | ||
Makefile | ||
pwm-ab8500.c | ||
pwm-atmel-hlcdc.c | ||
pwm-atmel-tcb.c | ||
pwm-atmel.c | ||
pwm-bcm2835.c | ||
pwm-bcm-kona.c | ||
pwm-bfin.c | ||
pwm-clps711x.c | ||
pwm-ep93xx.c | ||
pwm-fsl-ftm.c | ||
pwm-img.c | ||
pwm-imx.c | ||
pwm-jz4740.c | ||
pwm-lp3943.c | ||
pwm-lpc32xx.c | ||
pwm-lpss-pci.c | ||
pwm-lpss-platform.c | ||
pwm-lpss.c | ||
pwm-lpss.h | ||
pwm-mxs.c | ||
pwm-pca9685.c | ||
pwm-puv3.c | ||
pwm-pxa.c | ||
pwm-renesas-tpu.c | ||
pwm-rockchip.c | ||
pwm-samsung.c | ||
pwm-spear.c | ||
pwm-sti.c | ||
pwm-sun4i.c | ||
pwm-tegra.c | ||
pwm-tiecap.c | ||
pwm-tiehrpwm.c | ||
pwm-tipwmss.c | ||
pwm-tipwmss.h | ||
pwm-twl-led.c | ||
pwm-twl.c | ||
pwm-vt8500.c | ||
sysfs.c |