mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Richard GENOUD <richard.genoud@bootlin.com>
Cc: James Hilliard <james.hilliard1@gmail.com>,
	 Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	Chen-Yu Tsai <wens@kernel.org>,
	 Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	 Maxime Ripard <mripard@kernel.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	 Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	 Brian Masney <bmasney@redhat.com>,
	linux-pwm@vger.kernel.org, devicetree@vger.kernel.org,
	 linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
	 Paul Kocialkowski <paulk@sys-base.io>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	 John Stultz <jstultz@google.com>,
	Joao Schim <joao@schimsalabim.eu>,
	bigunclemax@gmail.com,  linux-clk@vger.kernel.org
Subject: Re: [PATCH v8 2/4] pwm: sun8i: Add H616 PWM support
Date: Wed, 23 Sep 2026 12:11:39 +0200	[thread overview]
Message-ID: <arOif-bN6JgLeWd3@monoceros> (raw)
In-Reply-To: <58145d8f-dd16-4cc2-b2ea-d475462241ab@bootlin.com>

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

On Wed, Sep 23, 2026 at 09:16:28AM +0200, Richard GENOUD wrote:
> Le 22/09/2026 à 17:46, James Hilliard a écrit :
> > The resolution tradeoff is real, but the waveform API currently specifies
> > the ordering: choose the largest period not exceeding the request, then
> > the largest compatible duty length not exceeding the request, then the
> > offset. That's the ordering implemented in v9.
>
> The ordering stated by pwm_round_waveform_might_sleep() documentation is
> period_length_ns, duty_length_ns and then duty_offset_ns, but what about
> duty steps?
> It's not stated in there because it's not a user input, but still, it's a
> quite important value for a pulse width *modulator*.

From my POV as someone who cares about many PWM lowlevel drivers, it
would be ideal if there would be a generic function that only relies on
conforming and ideally simple lowlevel drivers and work out a good
period that makes the required amount of duty steps available.

When I designed the requirements for the round-to-hw function I had in
mind that it should be possible to find the next higher possible period
for a given lower bound (and that works, only lacks implementation).
Working out a period that has finegrained duty steps is harder but
doable:

But something like that should work:

 - Pick a period P
 - P*, D*, _ = round_to_hw(period=P, duty_cycle=P-1, duty_offset=0)
 - Either take P* - D* as a measure for the finegrainedness, or continue
   to research available steps using round_to_hw(period=P*,
   duty_cycle=P*-1, duty_offset=0)
 - If there are too little steps pick a different P and retry.

Best regards
Uwe

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

  parent reply	other threads:[~2026-09-23 10:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 21:27 [PATCH v8 0/4] Introduce Allwinner H616 PWM controller James Hilliard
2026-08-04 21:27 ` [PATCH v8 1/4] dt-bindings: pwm: allwinner: add h616 pwm compatible James Hilliard
2026-08-04 21:27 ` [PATCH v8 2/4] pwm: sun8i: Add H616 PWM support James Hilliard
2026-09-21 16:28   ` Uwe Kleine-König
2026-09-22  0:27     ` James Hilliard
2026-09-22 15:13       ` Richard GENOUD
2026-09-22 15:46         ` James Hilliard
2026-09-23  7:16           ` Richard GENOUD
2026-09-23  8:01             ` James Hilliard
2026-09-23  8:52               ` Richard GENOUD
2026-09-23  8:59                 ` James Hilliard
2026-09-23 10:11             ` Uwe Kleine-König [this message]
2026-09-23 20:13               ` James Hilliard
2026-08-04 21:27 ` [PATCH v8 3/4] arm64: dts: allwinner: h616: add PWM controller James Hilliard
2026-08-04 21:27 ` [PATCH v8 4/4] MAINTAINERS: Add entry on Allwinner sun8i/H616 PWM driver James Hilliard

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=arOif-bN6JgLeWd3@monoceros \
    --to=ukleinek@kernel.org \
    --cc=bigunclemax@gmail.com \
    --cc=bmasney@redhat.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=joao@schimsalabim.eu \
    --cc=jstultz@google.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=mripard@kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    --cc=paulk@sys-base.io \
    --cc=richard.genoud@bootlin.com \
    --cc=robh@kernel.org \
    --cc=samuel@sholland.org \
    --cc=sboyd@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wens@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

all inboxes | Powered by JetHome®