From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Mikko Perttunen <mperttunen@nvidia.com>
Cc: Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>,
linux-pwm@vger.kernel.org, linux-tegra@vger.kernel.org,
linux-kernel@vger.kernel.org, Yi-Wei Wang <yiweiw@nvidia.com>
Subject: Re: [PATCH 1/5] pwm: tegra: Avoid hard-coded max clock frequency
Date: Tue, 24 Mar 2026 17:45:14 +0100 [thread overview]
Message-ID: <acKggw9F7oULLEuJ@monoceros> (raw)
In-Reply-To: <20260323-t264-pwm-v1-1-4c4ff743050f@nvidia.com>
[-- Attachment #1: Type: text/plain, Size: 2483 bytes --]
On Mon, Mar 23, 2026 at 11:36:37AM +0900, Mikko Perttunen wrote:
> From: Yi-Wei Wang <yiweiw@nvidia.com>
>
> The clock driving the Tegra PWM IP can be sourced from different parent
> clocks. Hence, let dev_pm_opp_set_rate() set the max clock rate based
> upon the current parent clock that can be specified via device-tree.
>
> After this, the Tegra194 SoC data becomes redundant, so get rid of it.
>
> Signed-off-by: Yi-Wei Wang <yiweiw@nvidia.com>
> Co-developed-by: Mikko Perttunen <mperttunen@nvidia.com>
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---
> drivers/pwm/pwm-tegra.c | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
> index 172063b51d44..759b98b97b6e 100644
> --- a/drivers/pwm/pwm-tegra.c
> +++ b/drivers/pwm/pwm-tegra.c
> @@ -59,9 +59,6 @@
>
> struct tegra_pwm_soc {
> unsigned int num_channels;
> -
> - /* Maximum IP frequency for given SoCs */
> - unsigned long max_frequency;
> };
>
> struct tegra_pwm_chip {
> @@ -303,7 +300,7 @@ static int tegra_pwm_probe(struct platform_device *pdev)
> return ret;
>
> /* Set maximum frequency of the IP */
> - ret = dev_pm_opp_set_rate(&pdev->dev, pc->soc->max_frequency);
> + ret = dev_pm_opp_set_rate(&pdev->dev, S64_MAX);
The documentation comment for dev_pm_opp_set_rate() reads:
Device wanting to run at fmax provided by the opp, should have
already rounded to the target OPP's frequency.
I think using S64_MAX is technically fine (assuming there are no issues
with big numbers in that function), but still it feels wrong to use
something simpler than the comment suggests. Am I missing something?
> if (ret < 0) {
> dev_err(&pdev->dev, "Failed to set max frequency: %d\n", ret);
> goto put_pm;
> @@ -318,7 +315,7 @@ static int tegra_pwm_probe(struct platform_device *pdev)
>
> /* Set minimum limit of PWM period for the IP */
> pc->min_period_ns =
> - (NSEC_PER_SEC / (pc->soc->max_frequency >> PWM_DUTY_WIDTH)) + 1;
> + (NSEC_PER_SEC / (pc->clk_rate >> PWM_DUTY_WIDTH)) + 1;
Orthogonal to this patch: Should this be
DIV_ROUND_UP(NSEC_PER_SEC, pc->clk_rate >> PWM_DUTY_WIDTH)
? Or even
DIV_ROUND_UP(NSEC_PER_SEC < PWM_DUTY_WIDTH, pc->clk_rate);
? (Note, the latter doesn't work as is, as the first parameter has an
overflow, I guess you're still getting my question.)
Best regards
Uwe
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2026-03-24 16:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 2:36 [PATCH 0/5] Tegra264 PWM support Mikko Perttunen
2026-03-23 2:36 ` [PATCH 1/5] pwm: tegra: Avoid hard-coded max clock frequency Mikko Perttunen
2026-03-24 16:45 ` Uwe Kleine-König [this message]
2026-03-25 0:34 ` Mikko Perttunen
2026-03-25 6:12 ` Uwe Kleine-König
2026-03-25 6:42 ` Viresh Kumar
2026-03-23 2:36 ` [PATCH 2/5] pwm: tegra: Modify read/write accessors for multi-register channel Mikko Perttunen
2026-03-23 2:36 ` [PATCH 3/5] pwm: tegra: Parametrize enable register offset Mikko Perttunen
2026-03-23 2:36 ` [PATCH 4/5] pwm: tegra: Parametrize duty and scale field widths Mikko Perttunen
2026-03-23 2:36 ` [PATCH 5/5] pwm: tegra: Add support for Tegra264 Mikko Perttunen
2026-03-23 7:24 ` Krzysztof Kozlowski
2026-03-24 4:46 ` Mikko Perttunen
2026-03-23 7:24 ` [PATCH 0/5] Tegra264 PWM support Krzysztof Kozlowski
2026-03-24 4:46 ` Mikko Perttunen
2026-03-24 16:45 ` Uwe Kleine-König
2026-03-24 23:55 ` Mikko Perttunen
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=acKggw9F7oULLEuJ@monoceros \
--to=ukleinek@kernel.org \
--cc=jonathanh@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=mperttunen@nvidia.com \
--cc=thierry.reding@gmail.com \
--cc=yiweiw@nvidia.com \
/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