Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bas Vermeulen <bas.vermeulen@blackstar.nl>
To: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Cc: "Uwe Kleine-König" <ukleinek@kernel.org>,
	"Lee Jones" <lee@kernel.org>, "Heiko Stuebner" <heiko@sntech.de>,
	"Damon Ding" <damon.ding@rock-chips.com>,
	kernel@collabora.com, linux-pwm@vger.kernel.org,
	linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 3/6] pwm: Add rockchip PWMv4 driver
Date: Thu, 29 Oct 2026 10:22:30 +0100	[thread overview]
Message-ID: <auMQVkm3liY6C2GU@blackstar.nl> (raw)
In-Reply-To: <20260420-rk3576-pwm-v5-3-ae7cfbbe5427@collabora.com>

Hi Nicolas,

On Mon, Apr 20, 2026 at 06:52:40 PDT, Nicolas Frattaroli wrote:
> The Rockchip RK3576 brings with it a new PWM IP, in downstream code
> referred to as "v4". This new IP is different enough from the previous
> Rockchip IP that I felt it necessary to add a new driver for it, instead
> of shoehorning it in the old one.

The same IP block is in the RK3506 (Cortex-A7, arm32), where I am
carrying this series on top of 7.3. It works there, driving a PWM
backlight and a pwm-regulator for the core voltage, but two things in
this patch need adjusting for it to build on a 32-bit kernel and on
current mainline:

> +	if (rate) {
> +		wf->period_length_ns = DIV_ROUND_UP((u64)wfhw->period * NSEC_PER_SEC, rate);
> +		wf->duty_length_ns = DIV_ROUND_UP((u64)wfhw->duty * NSEC_PER_SEC, rate);
> +		wf->duty_offset_ns = DIV_ROUND_UP((u64)wfhw->offset * NSEC_PER_SEC, rate);

DIV_ROUND_UP() with a u64 numerator is a plain 64-bit division, which on
arm32 becomes a call to __aeabi_uldivmod that the kernel does not
provide:

  pwm-rockchip-v4.o: undefined reference to `__aeabi_uldivmod'

DIV_ROUND_UP_ULL() goes through div_u64() and works on both:

-		wf->period_length_ns = DIV_ROUND_UP((u64)wfhw->period * NSEC_PER_SEC, rate);
-		wf->duty_length_ns = DIV_ROUND_UP((u64)wfhw->duty * NSEC_PER_SEC, rate);
-		wf->duty_offset_ns = DIV_ROUND_UP((u64)wfhw->offset * NSEC_PER_SEC, rate);
+		wf->period_length_ns = DIV_ROUND_UP_ULL((u64)wfhw->period * NSEC_PER_SEC, rate);
+		wf->duty_length_ns = DIV_ROUND_UP_ULL((u64)wfhw->duty * NSEC_PER_SEC, rate);
+		wf->duty_offset_ns = DIV_ROUND_UP_ULL((u64)wfhw->offset * NSEC_PER_SEC, rate);

Since MFD_ROCKCHIP_MFPWM allows COMPILE_TEST this will also show up in
32-bit allmodconfig builds.

> +	/*
> +	 * For referencing the PWM in the DT to work, we need the parent MFD
> +	 * device's OF node.
> +	 */
> +	dev->of_node_reused = true;

struct device no longer has that member: since 7.2 the flag lives in
the device flag word (commit 4aca5e62f37d "driver core: Replace
dev->of_node_reused with dev_of_node_reused()"), so this does not compile
against current mainline. The accessor is:

-	dev->of_node_reused = true;
+	dev_set_of_node_reused(dev);

With those two changes the driver builds and runs on the RK3506 with
7.3.y; happy to add a Tested-by for that if useful.

Regards,
Bas


  parent reply	other threads:[~2026-10-29  9:22 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-20 13:52 [PATCH v5 0/6] Add Rockchip RK3576 PWM Support Through MFPWM Nicolas Frattaroli
2026-04-20 13:52 ` [PATCH v5 1/6] dt-bindings: pwm: Add a new binding for rockchip,rk3576-pwm Nicolas Frattaroli
2026-07-10 10:31   ` Uwe Kleine-König
2026-04-20 13:52 ` [PATCH v5 2/6] mfd: Add Rockchip mfpwm driver Nicolas Frattaroli
2026-05-14 11:41   ` Lee Jones
2026-05-20 15:38     ` Nicolas Frattaroli
2026-04-20 13:52 ` [PATCH v5 3/6] pwm: Add rockchip PWMv4 driver Nicolas Frattaroli
2026-04-26  9:44   ` Damon Ding
2026-04-26 13:06     ` Uwe Kleine-König
2026-04-27  1:20       ` Damon Ding
2026-04-26 10:09   ` Damon Ding
2026-07-10 11:02   ` Uwe Kleine-König
2026-07-17  2:38     ` Damon Ding
2026-10-29  9:22   ` Bas Vermeulen [this message]
2026-10-29  9:25   ` Bas Vermeulen
2026-04-20 13:52 ` [PATCH v5 4/6] counter: Add rockchip-pwm-capture driver Nicolas Frattaroli
2026-04-26 10:55   ` Damon Ding
2026-04-27 17:35     ` Nicolas Frattaroli
2026-05-03 11:06       ` William Breathitt Gray
2026-05-03 10:46   ` William Breathitt Gray
2026-05-04  8:25     ` Nicolas Frattaroli
2026-04-20 13:52 ` [PATCH v5 5/6] arm64: dts: rockchip: add PWM nodes to RK3576 SoC dtsi Nicolas Frattaroli
2026-04-26  7:30   ` Damon Ding
2026-04-20 13:52 ` [PATCH v5 6/6] arm64: dts: rockchip: Add cooling fan to ROCK 4D Nicolas Frattaroli
2026-04-26  7:23   ` Damon Ding
2026-04-27 17:17     ` Nicolas Frattaroli
2026-04-21 15:56 ` [PATCH v5 0/6] Add Rockchip RK3576 PWM Support Through MFPWM Jonathan Cameron
2026-04-22 11:31   ` Nicolas Frattaroli
2026-04-24 10:43     ` Uwe Kleine-König

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=auMQVkm3liY6C2GU@blackstar.nl \
    --to=bas.vermeulen@blackstar.nl \
    --cc=damon.ding@rock-chips.com \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=nicolas.frattaroli@collabora.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