Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mikko Perttunen" <mperttunen@nvidia.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v6 6/7] pwm: tegra: Add support for Tegra264
Date: Wed, 01 Jul 2026 03:30:46 +0000	[thread overview]
Message-ID: <20260701033046.AF9C21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260701-t264-pwm-v6-6-2718f61f411f@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing initialization of CSR_1.DEPTH for Tegra264 can cause incorrect PWM frequency and duty cycle if the hardware reset state or bootloader configuration is not 255.
--

commit 3a866062b05a26bd8399e91a9683b58d16e08587
Author: Mikko Perttunen <mperttunen@nvidia.com>

pwm: tegra: Add support for Tegra264

This commit adds support for the Tegra264 PWM controller. It introduces
handling for a new register layout where the enable bit is moved to a
separate CSR_1 register.

> diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
> index ad75e4ee34102..5cdbe120ba2d8 100644
> --- a/drivers/pwm/pwm-tegra.c
> +++ b/drivers/pwm/pwm-tegra.c

[ ... ]

> @@ -215,6 +257,7 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>  
>  static int tegra_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
>  {
> +	struct tegra_pwm_chip *pc = to_tegra_pwm_chip(chip);
>  	int rc = 0;
>  	u32 val;
>  
> @@ -222,20 +265,21 @@ static int tegra_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
>  	if (rc)
>  		return rc;
>  
> -	val = tegra_pwm_readl(pwm, TEGRA_PWM_CSR_0);
> +	val = tegra_pwm_readl(pwm, pc->soc->enable_reg);
>  	val |= TEGRA_PWM_ENABLE;
> -	tegra_pwm_writel(pwm, TEGRA_PWM_CSR_0, val);
> +	tegra_pwm_writel(pwm, pc->soc->enable_reg, val);

[Severity: Medium]
Will this lead to incorrect PWM frequency and duty cycle if the hardware
or bootloader does not initialize the DEPTH field to 255?

Since CSR_1 is read-modify-written here to set the enable bit, the DEPTH
field (bits 30:15) is left uninitialized and relies on the pre-existing
state from the bootloader or hardware defaults. 

However, in tegra_pwm_config(), the driver calculates the frequency
divider and duty cycle assuming a hardcoded depth of 256:

tegra_pwm_config()
    ...
    c *= TEGRA_PWM_DEPTH;
    c = DIV_ROUND_CLOSEST_ULL(c, period_ns);

If CSR_1.DEPTH is not set to 255 (which corresponds to a hardware depth
divisor of 256), could this mismatch result in incorrect frequencies
or clipping of the output duty cycle?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260701-t264-pwm-v6-0-2718f61f411f@nvidia.com?part=6

  reply	other threads:[~2026-07-01  3:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01  3:20 [PATCH v6 0/7] Tegra264 PWM support Mikko Perttunen
2026-07-01  3:20 ` [PATCH v6 1/7] dt-bindings: pwm: Document Tegra264 controller Mikko Perttunen
2026-07-01  3:20 ` [PATCH v6 2/7] pwm: tegra: Prefix driver-local macros and functions Mikko Perttunen
2026-07-01  3:20 ` [PATCH v6 3/7] pwm: tegra: Avoid hard-coded max clock frequency Mikko Perttunen
2026-07-01  3:36   ` sashiko-bot
2026-07-01  3:20 ` [PATCH v6 4/7] pwm: tegra: Modify read/write accessors for multi-register channel Mikko Perttunen
2026-07-01  3:20 ` [PATCH v6 5/7] pwm: tegra: Parametrize duty and scale field widths Mikko Perttunen
2026-07-01  3:20 ` [PATCH v6 6/7] pwm: tegra: Add support for Tegra264 Mikko Perttunen
2026-07-01  3:30   ` sashiko-bot [this message]
2026-07-01  3:20 ` [PATCH v6 7/7] arm64: tegra: Add PWM controllers on Tegra264 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=20260701033046.AF9C21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=mperttunen@nvidia.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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