mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: "Stephane Lepain" <stephanelepain@gmail.com>,
	"Uwe Kleine-König" <ukleinek@kernel.org>
Cc: linux-pwm@vger.kernel.org, Kenneth Kasilag <kenneth@kasilag.me>,
	George Moussalem <george.moussalem@outlook.com>,
	Devi Priya <quic_devipriy@quicinc.com>,
	Baruch Siach <baruch.siach@siklu.com>,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pwm: ipq: fix period calculation
Date: Fri, 31 Jul 2026 17:27:19 +0200	[thread overview]
Message-ID: <db3c439b-d5b2-41c5-a3f0-bb528843a85c@oss.qualcomm.com> (raw)
In-Reply-To: <20260731070542.155398-1-stephanelepain@gmail.com>

On 7/31/26 9:05 AM, Stephane Lepain wrote:
> From: Kenneth Kasilag <kenneth@kasilag.me>
> 
> ipq_pwm_apply() fixes pwm_div at its maximum and derives only pre_div
> from the requested period. Since the period spans
> (pre_div + 1) * (pwm_div + 1) input clocks, pinning pwm_div near its
> maximum forces pre_div towards zero for short periods: once pre_div
> rounds to 0 the shortest representable period is (pwm_div + 1) / clk_rate,
> and any shorter request is rejected outright:

[...]

>  	/*
> -	 * Pick the maximal value for PWM_DIV that still allows a
> -	 * 100% relative duty cycle. This allows a fine grained
> -	 * selection of duty cycles.
> +	 * The period spans (pre_div + 1) * (pwm_div + 1) input clocks. Rather
> +	 * than fixing pwm_div at its maximum (which gives usable duty
> +	 * resolution only for long periods and collapses to ~0% for short
> +	 * periods) search for the (pre_div, pwm_div) split whose period best
> +	 * approximates the request while leaving pwm_div large enough to
> +	 * resolve the duty cycle.
>  	 */

I think the comment can just go

> -	pwm_div = IPQ_PWM_MAX_DIV - 1;
> +	if (ipq_chip->clk_rate > 16ULL * GIGA)
> +		return -EINVAL;

That's a very fast clock..

[...]

> -	hi_div = hi_dur * (pre_div + 1);
> +	hi_div = (u64)hi_dur * (pre_div + 1);

This looks like a separate fix

Konrad

  reply	other threads:[~2026-07-31 15:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31  7:05 Stephane Lepain
2026-07-31 15:27 ` Konrad Dybcio [this message]
2026-07-31 19:29 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=db3c439b-d5b2-41c5-a3f0-bb528843a85c@oss.qualcomm.com \
    --to=konrad.dybcio@oss.qualcomm.com \
    --cc=baruch.siach@siklu.com \
    --cc=george.moussalem@outlook.com \
    --cc=kenneth@kasilag.me \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=quic_devipriy@quicinc.com \
    --cc=stephanelepain@gmail.com \
    --cc=ukleinek@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®