summaryrefslogtreecommitdiff
path: root/drivers/pwm/pwm-lpc18xx-sct.c
diff options
context:
space:
mode:
authorClemens Gruber <clemens.gruber@pqgruber.com>2015-07-23 17:19:02 +0200
committerThierry Reding <thierry.reding@gmail.com>2015-08-17 16:35:46 +0200
commit01ec8472009c973413d4dc6fb198f0cc40abb9b4 (patch)
tree4aee7941fad79f25ec0c1fd48e43c18a3c34f5a9 /drivers/pwm/pwm-lpc18xx-sct.c
parent4a627b52e47ee09348773a981f2097f69ff349ee (diff)
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>
Diffstat (limited to 'drivers/pwm/pwm-lpc18xx-sct.c')
0 files changed, 0 insertions, 0 deletions