]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
pwm: omap-dmtimer: Fix inaccurate period and duty cycle calculations
authorDavid Rivshin <drivshin@allworx.com>
Sat, 30 Jan 2016 04:26:51 +0000 (23:26 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 11 May 2016 09:21:29 +0000 (11:21 +0200)
commit0b3ece4d8ba3e1d17d5cef76e1493bf6b4088a3d
tree98103e3654286be4bd04f398dbb81c0c3ee5478b
parent452a55daa3653c4ada9f8f4f6dd027dc09695b15
pwm: omap-dmtimer: Fix inaccurate period and duty cycle calculations

commit f8caa792261c0edded20eba2b8fcc899a1b91819 upstream.

Fix the calculation of load_value and match_value. Currently they
are slightly too low, which produces a noticeably wrong PWM rate with
sufficiently short periods (i.e. when 1/period approaches clk_rate/2).

Example:
 clk_rate=32768Hz, period=122070ns, duty_cycle=61035ns (8192Hz/50% PWM)
 Correct values: load = 0xfffffffc, match = 0xfffffffd
 Current values: load = 0xfffffffa, match = 0xfffffffc
 effective PWM: period=183105ns, duty_cycle=91553ns (5461Hz/50% PWM)

Fixes: 6604c6556db9 ("pwm: Add PWM driver for OMAP using dual-mode timers")
Signed-off-by: David Rivshin <drivshin@allworx.com>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Tested-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pwm/pwm-omap-dmtimer.c