diff options
author | Uwe Kleine-König <u.kleine-koenig@baylibre.com> | 2025-04-23 11:57:15 +0200 |
---|---|---|
committer | Uwe Kleine-König <ukleinek@kernel.org> | 2025-04-30 09:01:03 +0200 |
commit | e373991eb9ff0a9617634017c7f19fd36ec4f208 (patch) | |
tree | c4bce0627130876ddd78c38f09dd59da8aa5f32d | |
parent | b6b5683e9692b7ea2d4ca875802ec00a2b78dd66 (diff) |
pwm: rzg2l-gpt: Accept requests for too high period length
The period setting is shared for each pair of PWM channels. So if the
twin channel is in use, the period must not be changed. According to the
usual practise to pick the next smaller possible period, accept a
request for a period that is bigger than the unchangable value.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Tested-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://lore.kernel.org/r/20250423095715.2952692-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
-rw-r--r-- | drivers/pwm/pwm-rzg2l-gpt.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/pwm/pwm-rzg2l-gpt.c b/drivers/pwm/pwm-rzg2l-gpt.c index 2ddbb13f50aa..360c8bf3b190 100644 --- a/drivers/pwm/pwm-rzg2l-gpt.c +++ b/drivers/pwm/pwm-rzg2l-gpt.c @@ -270,15 +270,19 @@ static int rzg2l_gpt_config(struct pwm_chip *chip, struct pwm_device *pwm, * prescale and period can NOT be modified when there are multiple IOs * in use with different settings. */ - if (rzg2l_gpt->channel_request_count[ch] > 1 && period_ticks != rzg2l_gpt->period_ticks[ch]) - return -EBUSY; + if (rzg2l_gpt->channel_request_count[ch] > 1) { + if (period_ticks < rzg2l_gpt->period_ticks[ch]) + return -EBUSY; + else + period_ticks = rzg2l_gpt->period_ticks[ch]; + } prescale = rzg2l_gpt_calculate_prescale(rzg2l_gpt, period_ticks); pv = rzg2l_gpt_calculate_pv_or_dc(period_ticks, prescale); duty_ticks = mul_u64_u64_div_u64(state->duty_cycle, rzg2l_gpt->rate_khz, USEC_PER_SEC); - if (duty_ticks > RZG2L_MAX_TICKS) - duty_ticks = RZG2L_MAX_TICKS; + if (duty_ticks > period_ticks) + duty_ticks = period_ticks; dc = rzg2l_gpt_calculate_pv_or_dc(duty_ticks, prescale); /* |