pwm: tiehrpwm: Fix corner case in clock divisor calculation
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Mon, 11 Aug 2025 16:01:02 +0000 (18:01 +0200)
committerUwe Kleine-König <ukleinek@kernel.org>
Mon, 15 Sep 2025 09:39:43 +0000 (11:39 +0200)
commit00f83f0e07e44e2f1fb94b223e77ab7b18ee2d7d
treef19be721cccffc2aa15ba024d483d75b48ce997a
parentbc7ce5bfc504eea9eac0eb0215017b9fcfc62c59
pwm: tiehrpwm: Fix corner case in clock divisor calculation

The function set_prescale_div() is responsible for calculating the clock
divisor settings such that the input clock rate is divided down such that
the required period length is at most 0x10000 clock ticks. If period_cycles
is an integer multiple of 0x10000, the divisor period_cycles / 0x10000 is
good enough. So round up in the calculation of the required divisor and
compare it using >= instead of >.

Fixes: 19891b20e7c2 ("pwm: pwm-tiehrpwm: PWM driver support for EHRPWM")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/85488616d7bfcd9c32717651d0be7e330e761b9c.1754927682.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
drivers/pwm/pwm-tiehrpwm.c