pwm: rockchip: fix the scaler calculation in &rockchip_pwm_funcs.set_wave()

If the pc->clk_rate is the same as config->clk_rate, the scaler should
be set to 0. However, using the previous calculation method, the result
would incorrectly be 1.

Fixes: 1504b8ffcf ("pwm: rockchip: add dclk scale config for wave generator mode")
Change-Id: I876f7f530ab841b485b8d7f139adcf825955a160
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
This commit is contained in:
Damon Ding
2025-01-16 09:17:04 +08:00
committed by Tao Huang
parent b125e2d8c7
commit dfaa59878d

View File

@@ -1652,7 +1652,7 @@ int rockchip_pwm_set_wave(struct pwm_device *pwm, struct rockchip_pwm_wave_confi
return -EINVAL;
}
pc->scaler = DIV_ROUND_CLOSEST_ULL(pc->clk_rate, config->clk_rate * 2);
pc->scaler = DIV_ROUND_CLOSEST_ULL(pc->clk_rate, config->clk_rate) / 2;
if (pc->scaler > 256) {
dev_err(chip->dev, "Unsupported scale factor %d(max: 512) for PWM%d\n",
pc->scaler * 2, pc->channel_id);