Devicetree
 help / color / mirror / Atom feed
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>,
	Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	linux-pwm@vger.kernel.org,  linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	 Thierry Reding <treding@nvidia.com>
Subject: Re: [PATCH v4 3/7] pwm: tegra: Modify read/write accessors for multi-register channel
Date: Sun, 17 May 2026 19:30:42 +0200	[thread overview]
Message-ID: <agn6i8SmO-jwYNhM@monoceros> (raw)
In-Reply-To: <20260331-t264-pwm-v4-3-c041659677cf@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 1685 bytes --]

On Tue, Mar 31, 2026 at 11:12:15AM +0900, Mikko Perttunen wrote:
> On Tegra264, each PWM instance has two registers (per channel, of which
> there is one). Update the pwm_readl/pwm_writel helper functions to
> take channel (as struct pwm_device *) and offset separately.
> 
> Reviewed-by: Thierry Reding <treding@nvidia.com>
> Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
> ---
>  drivers/pwm/pwm-tegra.c | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
> index 8a330169d531..358c81cea05b 100644
> --- a/drivers/pwm/pwm-tegra.c
> +++ b/drivers/pwm/pwm-tegra.c
> @@ -57,6 +57,8 @@
>  #define PWM_SCALE_WIDTH	13
>  #define PWM_SCALE_SHIFT	0
>  
> +#define PWM_CSR_0	0

Is this a register offset (of the for now single per channel register)?

One thing that bothers me about this driver is that the defines are not
prefixed by the driver name. `PWM_SCALE_WIDTH` looks more generic than
it is.

> +
>  struct tegra_pwm_soc {
>  	unsigned int num_channels;
>  };
> @@ -78,14 +80,18 @@ static inline struct tegra_pwm_chip *to_tegra_pwm_chip(struct pwm_chip *chip)
>  	return pwmchip_get_drvdata(chip);
>  }
>  
> -static inline u32 pwm_readl(struct tegra_pwm_chip *pc, unsigned int offset)
> +static inline u32 pwm_readl(struct pwm_device *dev, unsigned int offset)

s/dev/pwm/ to match the variable naming in the rest of the driver.

>  {
> -	return readl(pc->regs + (offset << 4));
> +	struct tegra_pwm_chip *chip = to_tegra_pwm_chip(dev->chip);
> +
> +	return readl(chip->regs + (dev->hwpwm * 16) + offset);

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-05-17 17:30 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31  2:12 [PATCH v4 0/7] Tegra264 PWM support Mikko Perttunen
2026-03-31  2:12 ` [PATCH v4 1/7] dt-bindings: pwm: Document Tegra264 controller Mikko Perttunen
2026-04-08 13:27   ` Rob Herring (Arm)
2026-03-31  2:12 ` [PATCH v4 2/7] pwm: tegra: Avoid hard-coded max clock frequency Mikko Perttunen
2026-03-31  7:29   ` Thierry Reding
2026-03-31  2:12 ` [PATCH v4 3/7] pwm: tegra: Modify read/write accessors for multi-register channel Mikko Perttunen
2026-05-17 17:30   ` Uwe Kleine-König [this message]
2026-05-18  2:31     ` Mikko Perttunen
2026-03-31  2:12 ` [PATCH v4 4/7] pwm: tegra: Parametrize enable register offset Mikko Perttunen
2026-03-31  7:30   ` Thierry Reding
2026-05-17 17:35   ` Uwe Kleine-König
2026-05-18  2:30     ` Mikko Perttunen
2026-03-31  2:12 ` [PATCH v4 5/7] pwm: tegra: Parametrize duty and scale field widths Mikko Perttunen
2026-03-31  2:12 ` [PATCH v4 6/7] pwm: tegra: Add support for Tegra264 Mikko Perttunen
2026-03-31  7:36   ` Thierry Reding
2026-03-31  2:12 ` [PATCH v4 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=agn6i8SmO-jwYNhM@monoceros \
    --to=ukleinek@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mperttunen@nvidia.com \
    --cc=robh@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=treding@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