From: Andrea della Porta <andrea.porta@suse.com>
To: Sean Young <sean@mess.org>
Cc: "Andrea della Porta" <andrea.porta@suse.com>,
"Uwe Kleine-König" <ukleinek@kernel.org>,
linux-pwm@vger.kernel.org, "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Broadcom internal kernel review list"
<bcm-kernel-feedback-list@broadcom.com>,
devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Naushir Patuck" <naush@raspberrypi.com>,
"Stanimir Varbanov" <svarbanov@suse.de>,
mbrugger@suse.com
Subject: Re: [PATCH v5 2/3] pwm: rp1: Add RP1 PWM controller driver
Date: Fri, 3 Jul 2026 16:52:17 +0200 [thread overview]
Message-ID: <akfMoQfzmEEiH9VC@apocalypse> (raw)
In-Reply-To: <aiwX2YWVJnDNTNiu@extorris.mess.org>
Hi Sean,
On 15:29 Fri 12 Jun , Sean Young wrote:
> On Fri, Jun 12, 2026 at 04:01:27PM +0200, Andrea della Porta wrote:
> > From: Naushir Patuck <naush@raspberrypi.com>
> >
> > The Raspberry Pi RP1 southbridge features an embedded PWM
> > controller with 4 output channels, alongside an RPM interface
> > to read the fan speed on the Raspberry Pi 5.
> >
> > Add the supporting driver.
> >
<...snip...>
>
> I don't understand the point of the clk_enabled field. If the probe
> function succeeds, then clk_enabled = true. It is set to false during
> suspend, but after suspend the only thing which can follow is resume,
> I think. In resume, we set it in to true again unconditionally. So
> it is always true, no?
It's true unless enabling the clock again in rp1_pwm_resume() will fail.
That will trap the unbalanced condition mentioned by Uwe in:
https://lore.kernel.org/all/adiW1tBC8Imd14LD@monoceros/
>
> > +};
> > +
> > +struct rp1_pwm_waveform {
> > + u32 period_ticks;
> > + u32 duty_ticks;
> > + bool enabled;
> > + bool inverted_polarity;
> > +};
> > +
<...snip...>
> > +
> > + /*
> > + * The period is limited to U32_MAX, and it will be decremented by one later
> > + * to allow 100% duty cycle.
> > + */
> > + if (period_ticks > U32_MAX) {
> > + period_ticks = U32_MAX;
> > + } else if (period_ticks < 2) {
> > + period_ticks = 2;
> > + ret = 1;
> > + }
>
> period_ticks = clamp(period_ticks, 2, U32_MAX);
>
> Although that misses out the `ret = 1;` which I am not sure about anyway.
But we need that ret = 1 to announce that values have been rounded.
>
> > +
> > + duty_ticks = mul_u64_u64_div_u64(wf->duty_length_ns, clk_rate, NSEC_PER_SEC);
> > + duty_ticks = min(duty_ticks, period_ticks);
> > + offset_ticks = mul_u64_u64_div_u64(wf->duty_offset_ns, clk_rate, NSEC_PER_SEC);
> > + if (offset_ticks >= period_ticks)
> > + offset_ticks %= period_ticks;
> > + if (duty_ticks && offset_ticks &&
> > + ret = dev_err_probe(dev, -EINVAL, "Clock rate > 1 GHz is not supported\n");
<...snip...>
> > + goto err_disable_clk;
> > + }
> > + rp1->clk_rate = clk_rate;
> > +
> > + chip->ops = &rp1_pwm_ops;
>
> Can we add the following please:
>
> chip->atomic = true;
>
> This means that the pwm can be controlled from atomic context (not process
> context) using pwm_apply_atomic(). This is very helpful for the pwm-ir-tx
> driver, which produces a much more faithful IR signal in atomic context.
>
> Using pwm for infrared tx is much nicer than using gpio which bit bangs
> the IR signal and holds the CPU with interrupts disabled for upto one second.
>
> As far as I can see there is no sleeping code in these code paths, so we
> should be fine.
Sure, added.
Many thanks,
Andrea
>
> Thanks,
>
> Sean
>
<...snip...>
next prev parent reply other threads:[~2026-07-03 14:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 14:01 [PATCH v5 0/3] Add RP1 PWM controller support Andrea della Porta
2026-06-12 14:01 ` [PATCH v5 1/3] dt-bindings: pwm: Add Raspberry Pi RP1 PWM controller Andrea della Porta
2026-06-12 14:05 ` sashiko-bot
2026-06-12 15:24 ` Stanimir Varbanov
2026-06-26 17:09 ` Andrea della Porta
2026-06-12 14:01 ` [PATCH v5 2/3] pwm: rp1: Add RP1 PWM controller driver Andrea della Porta
2026-06-12 14:13 ` sashiko-bot
2026-06-12 14:29 ` Sean Young
2026-07-03 14:52 ` Andrea della Porta [this message]
2026-06-13 12:27 ` Julian Braha
2026-06-15 6:37 ` Uwe Kleine-König
2026-06-15 10:29 ` Julian Braha
2026-07-03 14:56 ` Andrea della Porta
2026-07-03 16:38 ` Julian Braha
2026-06-12 14:01 ` [PATCH v5 3/3] arm64: dts: broadcom: rpi-5: Add RP1 PWM node Andrea della Porta
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=akfMoQfzmEEiH9VC@apocalypse \
--to=andrea.porta@suse.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=mbrugger@suse.com \
--cc=naush@raspberrypi.com \
--cc=robh@kernel.org \
--cc=sean@mess.org \
--cc=svarbanov@suse.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.