linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: "Mark Brown" <broonie@kernel.org>,
	"Doug Anderson" <dianders@google.com>,
	"Heiko Stübner" <heiko@sntech.de>,
	linux-pwm <linux-pwm@vger.kernel.org>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Jingoo Han" <jingoohan1@gmail.com>,
	"Lee Jones" <lee.jones@linaro.org>,
	linux-fbdev@vger.kernel.org, "Bryan Wu" <cooloney@gmail.com>,
	"Richard Purdie" <rpurdie@rpsys.net>,
	"Jacek Anaszewski" <j.anaszewski@samsung.com>,
	linux-leds@vger.kernel.org,
	"Maxime Ripard" <maxime.ripard@free-electrons.com>,
	linux-sunxi@googlegroups.com,
	"open list:ARM/Rockchip SoC..."
	<linux-rockchip@lists.infradead.org>,
	"Jean-Christophe Plagniol-Villard" <plagnioj@jcrosoft.com>,
	"Tomi Valkeinen" <tomi.valkeinen@ti.com>,
	"Daniel Mack" <daniel@zonque.org>,
	"Haojian Zhuang" <haojian.zhuang@gmail.com>,
	"Robert Jarzmik" <robert.jarzmik@free.fr>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Olof Johansson" <olof@lixom.net>
Subject: Re: [PATCH v3 00/12] pwm: add support for atomic update
Date: Tue, 23 Feb 2016 15:57:32 +0100	[thread overview]
Message-ID: <20160223145732.GB27656@ulmo> (raw)
In-Reply-To: <20160204150150.553d36df@bbrezillon>

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

On Thu, Feb 04, 2016 at 03:01:50PM +0100, Boris Brezillon wrote:
> Hi Mark, Thierry,
> 
> On Thu, 4 Feb 2016 11:02:03 +0000
> Mark Brown <broonie@kernel.org> wrote:
> 
> > On Wed, Feb 03, 2016 at 11:04:20AM -0800, Doug Anderson wrote:
> > 
> > > Sure.  ...but you agree that somehow you need a new API call for this,
> > > right?  Somehow the PWM regulator needs to be able to say that it
> > > wants the hardware state, not the initial state as specified in the
> > > device tree.
> > 
> > Wouldn't the most direct way to do that be to just not specify anything
> > in the DT?  If there *is* something in DT but we ignore it that's a bit
> > weird.
> 
> Just adding some inputs on this specific aspect. The reason we have to
> specify a period (and, to a lesser extent, the polarity) in the DT or
> PWM lookup table is because what most PWM users want is to specify a
> dutycycle relatively to a predefined period value.

That's not quite correct. The reason why we need the information in DT
is because it can't be derived from anything else. It is board-specific
data for which there's no heuristic that will work in all cases.

> If we decide to remove those information from the DT, then you'll need
> a way to define it somewhere else, and then the is question is 'where?'.
> 
> Users that really want to control their period (this could the case for
> the clk-pwm driver) could completely ignore DT/lookup-table information
> and set the period and absolute dutycycle directly.

Yes, I think clk-pwm is very special in this regard because the period
can be derived from the requested clock rate. It would be complicated to
implement DT parsing that ignores parts of the specifier in some cases
but not in others. Simply having the clk-pwm driver ignore whatever is
in the table (or perhaps bail out on periods other than 0 for example).

> Now, from what I seen, what most PWM users want to do is:
> 
> 	pwm_set_rel_duty_scale(pwm, rel_value, scale);
> or 
> 	rel_duty = pwm_get_rel_duty_cycle(pwm, scale);
> 
> where scale depends on the precision you need for your use case (most
> of the time it's expressed in percent).
> 
> So, how about providing this kind of API (this is what I proposed in
> one of my previous email)?
> 
> This would not only solve our problem (say you have a period at
> boot-time that differs from the one you'll set when first applying a
> new relative duty cycle, then the resulting relative value would still
> be correct), but it would also remove a lot of boiler plate code from
> PWM users code (if you take a look at pwm-regulator, pwm-leds, pwm-fan
> and probably others, you'll see that they are all doing this conversion
> manually).

I don't think this gains us much. The above would work for pwm-regulator
and pwm-fan, in both cases it'd replace a single line with two lines and
fitting the expressions into function arguments is likely going to be
hideous. For leds-pwm this wouldn't work, because of the low-active case
that it supports.

> Now, the last blocking point is, what if the PWM driver does not
> implement HW-readout. In this case, the pwm-regulator will probably
> expose a 0V output (IIRC, dutycycle is set to 0 by default) when it's
> actually providing something else. But is this really important? I
> mean, if the user really wants to have a reliable information, then he
> will implement initial-state retrieval in its PWM controller driver.
> Alternatively, we could put a flag specifying whether the PWM chip
> supports initial state retrieval.

I reached the same conclusion in another subthread. If hardware readout
isn't supported, I think the most natural thing to do is simply use the
initial state (i.e. what's defined in DT or board files) instead. There
is an argument, I think, to be made for having users apply the initial
state at probe time to forcibly apply the logical state to hardware and
subsequently not care about the initial state anymore. For most cases
that might not even be necessary, though.

Thierry

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

  reply	other threads:[~2016-02-23 14:57 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-21  9:33 [PATCH v3 00/12] pwm: add support for atomic update Boris Brezillon
2015-09-21  9:33 ` [PATCH v3 01/12] pwm: introduce default period and polarity concepts Boris Brezillon
2015-09-21 18:20   ` Robert Jarzmik
2015-09-22  6:36   ` Jacek Anaszewski
2015-09-22 21:49   ` Lee Jones
2015-11-07  2:35   ` Alexandre Belloni
2015-09-21  9:33 ` [PATCH v3 02/12] pwm: define a new pwm_state struct Boris Brezillon
2015-09-21  9:33 ` [PATCH v3 03/12] pwm: move the enabled/disabled info to " Boris Brezillon
2015-09-21  9:33 ` [PATCH v3 04/12] backlight: pwm_bl: remove useless call to pwm_set_period Boris Brezillon
2015-09-22 22:12   ` Lee Jones
2015-09-21  9:33 ` [PATCH v3 05/12] pwm: declare a default PWM state Boris Brezillon
2015-09-21  9:33 ` [PATCH v3 06/12] pwm: add the PWM initial state retrieval infra Boris Brezillon
2015-09-21  9:33 ` [PATCH v3 07/12] pwm: add the core infrastructure to allow atomic update Boris Brezillon
2015-09-21  9:33 ` [PATCH v3 08/12] pwm: add information about polarity, duty cycle and period to debugfs Boris Brezillon
2015-09-21  9:33 ` [PATCH v3 09/12] pwm: rockchip: add initial state retrieval Boris Brezillon
2015-09-21  9:33 ` [PATCH v3 10/12] pwm: rockchip: add support for atomic update Boris Brezillon
2015-09-21  9:33 ` [PATCH v3 11/12] regulator: pwm: implement ->enable(), ->disable() and ->is_enabled methods Boris Brezillon
2015-09-21 21:13   ` Mark Brown
2015-09-21  9:33 ` [PATCH v3 12/12] regulator: pwm: properly initialize the ->state field Boris Brezillon
2015-09-21 21:10   ` Mark Brown
2015-09-21 22:30 ` [PATCH v3 00/12] pwm: add support for atomic update Heiko Stübner
2015-10-09 21:02 ` Boris Brezillon
2015-10-10 15:11 ` [PATCH v3 pre-03/12] pwm: rcar: make use of pwm_is_enabled() Boris Brezillon
2015-10-19 10:12 ` [PATCH v3 00/12] pwm: add support for atomic update Heiko Stübner
2015-11-10 17:34   ` Thierry Reding
2015-11-10 18:26     ` Boris Brezillon
2016-01-25 16:28     ` Doug Anderson
2016-01-25 17:08       ` Thierry Reding
2016-01-25 17:55         ` Boris Brezillon
2016-01-25 18:51         ` Doug Anderson
2016-02-03 14:53           ` Thierry Reding
2016-02-03 19:04             ` Doug Anderson
2016-02-04 11:02               ` Mark Brown
2016-02-04 14:01                 ` Boris Brezillon
2016-02-23 14:57                   ` Thierry Reding [this message]
2016-02-22 16:27               ` Doug Anderson
2016-02-22 17:59               ` Thierry Reding
2016-02-22 19:15                 ` Doug Anderson
2016-02-22 21:24                   ` Mark Brown
2016-02-23  3:03                     ` Doug Anderson
2016-02-23 14:38                   ` Thierry Reding
2016-02-23 17:35                     ` Doug Anderson
2016-02-23 18:14                       ` Thierry Reding
2016-02-23 18:42                         ` Doug Anderson
2016-02-25 23:14                           ` Doug Anderson
2016-03-07 16:34                             ` Doug Anderson
2016-03-10 17:54                               ` Thierry Reding
2016-03-11  9:51                                 ` Boris Brezillon

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=20160223145732.GB27656@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=broonie@kernel.org \
    --cc=cooloney@gmail.com \
    --cc=daniel@zonque.org \
    --cc=dianders@google.com \
    --cc=haojian.zhuang@gmail.com \
    --cc=heiko@sntech.de \
    --cc=j.anaszewski@samsung.com \
    --cc=jingoohan1@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-sunxi@googlegroups.com \
    --cc=maxime.ripard@free-electrons.com \
    --cc=olof@lixom.net \
    --cc=plagnioj@jcrosoft.com \
    --cc=robert.jarzmik@free.fr \
    --cc=rpurdie@rpsys.net \
    --cc=tomi.valkeinen@ti.com \
    --cc=u.kleine-koenig@pengutronix.de \
    /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).