linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Clemens Gruber <clemens.gruber@pqgruber.com>
Cc: linux-pwm@vger.kernel.org,
	Thierry Reding <thierry.reding@gmail.com>,
	Sven Van Asbroeck <TheSven73@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 4/7] pwm: pca9685: Support staggered output ON times
Date: Thu, 1 Apr 2021 22:58:19 +0200	[thread overview]
Message-ID: <20210401205819.soloiozcrgq4eool@pengutronix.de> (raw)
In-Reply-To: <YGRqZsi4WApZcwIT@workstation.tuxnet>

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

Hello Clemens,

On Wed, Mar 31, 2021 at 02:26:14PM +0200, Clemens Gruber wrote:
> On Mon, Mar 29, 2021 at 08:02:06PM +0200, Uwe Kleine-König wrote:
> > On Mon, Mar 29, 2021 at 07:16:38PM +0200, Clemens Gruber wrote:
> > > On Mon, Mar 29, 2021 at 07:03:57PM +0200, Uwe Kleine-König wrote:
> > > > On Mon, Mar 29, 2021 at 02:57:04PM +0200, Clemens Gruber wrote:
> > > > > The PCA9685 supports staggered LED output ON times to minimize current
> > > > > surges and reduce EMI.
> > > > > When this new option is enabled, the ON times of each channel are
> > > > > delayed by channel number x counter range / 16, which avoids asserting
> > > > > all enabled outputs at the same counter value while still maintaining
> > > > > the configured duty cycle of each output.
> > > > > 
> > > > > Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
> > > > 
> > > > Is there a reason to not want this staggered output? If it never hurts I
> > > > suggest to always stagger and drop the dt property.
> > > 
> > > There might be applications where you want multiple outputs to assert at
> > > the same time / to be synchronized.
> > > With staggered outputs mode always enabled, this would no longer be
> > > possible as they are spread out according to their channel number.
> > > 
> > > Not sure how often that usecase is required, but just enforcing the
> > > staggered mode by default sounds risky to me.
> > 
> > There is no such guarantee in the PWM framework, so I don't think we
> > need to fear breaking setups. Thierry?
> 
> Still, someone might rely on it? But let's wait for Thierry's opinion.

Someone might rely on the pca9685 driver being as racy as a driver with
legacy bindings usually is. Should this be the reason to drop this whole
series?

> > One reason we might not want staggering is if we have a consumer who
> > cares about config transitions. (This however is moot it the hardware
> > doesn't provide sane transitions even without staggering.)
> > 
> > Did I already ask about races in this driver? I assume there is a
> > free running counter and the ON and OFF registers just define where in
> > the period the transitions happen, right? Given that changing ON and OFF
> > needs two register writes probably all kind of strange things can
> > happen, right? (Example thought: for simplicity's sake I assume ON is
> > always 0. Then if you want to change from OFF = 0xaaa to OFF = 0xccc we
> > might see a period with 0xacc. Depending on how the hardware works we
> > might even see 4 edges in a single period then.)
> 
> Yes, there is a free running counter from 0 to 4095.
> And it is probably true, that there can be short intermediate states
> with our two register writes.
> 
> There is a separate mode "Update on ACK" (MODE2 register, bit 3 "OCH"),
> which is 0 by default (Outputs change on STOP command) but could be set
> to 1 (Outputs change on ACK):
> "Update on ACK requires all 4 PWM channel registers to be loaded before
> outputs will change on the last ACK."

This is about the ACK and STOP in the i2c communication, right? I fail
to understand the relevance of this difference. I guess I have to read
the manual myself.
 
> The chip datasheet also states:
> "Because the loading of the LEDn_ON and LEDn_OFF registers is via the
> I2C-bus, and asynchronous to the internal oscillator, we want to ensure
> that we do not see any visual artifacts of changing the ON and OFF
> values. This is achieved by updating the changes at the end of the LOW
> cycle."

So we're only out of luck if the first register write happens before and
the second after the end of the LOW cycle, aren't we?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

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

  parent reply	other threads:[~2021-04-01 20:58 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 12:57 [PATCH v6 1/7] pwm: pca9685: Switch to atomic API Clemens Gruber
2021-03-29 12:57 ` [PATCH v6 2/7] pwm: pca9685: Support hardware readout Clemens Gruber
2021-03-29 15:51   ` Uwe Kleine-König
2021-03-29 16:33     ` Clemens Gruber
2021-03-29 16:54   ` Uwe Kleine-König
2021-03-29 17:11     ` Clemens Gruber
2021-03-29 17:41       ` Uwe Kleine-König
2021-03-29 12:57 ` [PATCH v6 3/7] pwm: pca9685: Improve runtime PM behavior Clemens Gruber
2021-03-29 15:55   ` Uwe Kleine-König
2021-03-29 16:31     ` Clemens Gruber
2021-03-29 12:57 ` [PATCH v6 4/7] pwm: pca9685: Support staggered output ON times Clemens Gruber
2021-03-29 17:03   ` Uwe Kleine-König
2021-03-29 17:16     ` Clemens Gruber
2021-03-29 18:02       ` Uwe Kleine-König
2021-03-31 12:26         ` Clemens Gruber
2021-03-31 13:55           ` Clemens Gruber
2021-04-01 20:59             ` Uwe Kleine-König
2021-04-01 21:53               ` Clemens Gruber
2021-03-31 16:21           ` Thierry Reding
2021-04-01  7:50             ` Clemens Gruber
2021-04-01 13:47               ` Thierry Reding
2021-04-01 15:19                 ` Clemens Gruber
2021-04-02 19:48             ` Uwe Kleine-König
2021-04-01 20:58           ` Uwe Kleine-König [this message]
2021-04-01 21:37             ` Clemens Gruber
2021-04-02 20:23           ` Uwe Kleine-König
2021-03-29 12:57 ` [PATCH v6 5/7] dt-bindings: pwm: pca9685: Add nxp,staggered-outputs property Clemens Gruber
2021-04-02 19:52   ` Uwe Kleine-König
2021-03-29 12:57 ` [PATCH v6 6/7] pwm: pca9685: Restrict period change for prescaler users Clemens Gruber
2021-03-29 17:15   ` Uwe Kleine-König
2021-03-29 17:33     ` Clemens Gruber
2021-03-29 17:49       ` Uwe Kleine-König
2021-03-29 12:57 ` [PATCH v6 7/7] pwm: pca9685: Add error messages for failed regmap calls Clemens Gruber

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=20210401205819.soloiozcrgq4eool@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=TheSven73@gmail.com \
    --cc=clemens.gruber@pqgruber.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).