linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Paul Cercueil <paul@crapouillou.net>,
	Linus Walleij <linus.walleij@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ralf Baechle <ralf@linux-mips.org>,
	paul.burton@mips.com, James Hogan <jhogan@kernel.org>,
	Jonathan Corbet <corbet@lwn.net>,
	Mathieu Malaterre <malat@debian.org>,
	ezequiel@collabora.co.uk, prasannatsmkumar@gmail.com,
	linux-pwm@vger.kernel.org,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
	<devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	LINUXWATCHDOG <linux-watchdog@vger.kernel.org>,
	linux-mips@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-clk <linux-clk@vger.kernel.org>,
	od@zcrc.me
Subject: Re: [PATCH v8 15/26] pwm: jz4740: Add support for the JZ4725B
Date: Thu, 20 Dec 2018 21:58:09 +0100	[thread overview]
Message-ID: <20181220205809.5t2klpb7donmoibb@pengutronix.de> (raw)
In-Reply-To: <20181220173904.GE9408@ulmo>

On Thu, Dec 20, 2018 at 06:39:04PM +0100, Thierry Reding wrote:
> On Mon, Dec 17, 2018 at 08:53:21AM +0100, Uwe Kleine-König wrote:
> > On Sun, Dec 16, 2018 at 03:18:52PM +0100, Paul Cercueil wrote:
> > > Hi,
> > > 
> > > Le ven. 14 déc. 2018 à 15:26, Uwe Kleine-König
> > > <u.kleine-koenig@pengutronix.de> a écrit :
> > > > Hello,
> > > > 
> > > > On Fri, Dec 14, 2018 at 02:50:20PM +0100, Linus Walleij wrote:
> > > > > On Thu, Dec 13, 2018 at 9:42 PM Uwe Kleine-König
> > > > > <u.kleine-koenig@pengutronix.de> wrote:
> > > > > > [Adding Linus Walleij to Cc:]
> > > > > > On Thu, Dec 13, 2018 at 03:03:15PM +0100, Paul Cercueil wrote:
> > > > > > > Le jeu. 13 déc. 2018 à 10:24, Uwe Kleine-König
> > > > > > > <u.kleine-koenig@pengutronix.de> a écrit :
> > > > > > > > On Wed, Dec 12, 2018 at 11:09:10PM +0100, Paul Cercueil wrote:
> > > > > > > > >  The PWM in the JZ4725B works the same as in the JZ4740,
> > > > > > > > >  except that it only has 6 channels available instead of
> > > > > > > > >  8.
> > > > > > > >
> > > > > > > > this driver is probed only from device tree? If yes, it
> > > > > > > > might be sensible to specify the number of PWMs there and
> > > > > > > > get it from there.
> > > > > > > > There doesn't seem to be a generic binding for that, but there are
> > > > > > > > several drivers that could benefit from it. (This is a bigger project
> > > > > > > > though and shouldn't stop your patch. Still more as it already got
> > > > > > > > Thierry's ack.)
> > > > > > >
> > > > > > > I think there needs to be a proper guideline, as there doesn't seem to be
> > > > > > > a consensus about this. I learned from emails with Rob and  Linus (Walleij)
> > > > > > > that I should not have in devicetree what I can deduce from the compatible
> > > > > > > string.
> > > > > >
> > > > > > I understood them a bit differently. It is ok to deduce things from the
> > > > > > compatible string. But if you define a generic property (say) "num-pwms"
> > > > > > that is used uniformly in most bindings this is ok, too. (And then the
> > > > > > two different devices could use the same compatible.)
> > > > > >
> > > > > > An upside of the generic "num-pwms" property is that the pwm core could
> > > > > > sanity check pwm phandles before passing them to the hardware drivers.
> > > > > 
> > > > >  I don't know if this helps, but in GPIO we have "ngpios" which is
> > > > >  used to augment an existing block as to the number of lines actually
> > > > >  used with it.
> > > > > 
> > > > >  The typical case is that an ASIC engineer synthesize a block for
> > > > >  32 GPIOs but only 12 of them are routed to external pads. So
> > > > >  we augment the behaviour of that driver to only use 12 of the
> > > > >  32 lines.
> > > > > 
> > > > >  I guess using the remaining 20 lines "works" in a sense but they
> > > > >  have no practical use and will just bias electrons in the silicon
> > > > >  for no use.
> > > > 
> > > > This looks very similar to the case under discussion.
> > > > 
> > > > >  So if the PWM case is something similar, then by all means add
> > > > >  num-pwms.
> > > > 
> > > > .. or "npwms" to use the same nomenclature as the gpio binding?
> > > 
> > > If we're going to do something like this, should it be the drivers or
> > > the core (within pwmchip_add) that checks for this "npwms" property?
> > 
> > Of course this should be done in the core. The driver than can rely on
> > the validity of the index. But as I wrote before, this shouldn't stop
> > your patch from going in.

Actually the core already takes care of the validity of the index with
the number of pwms being provided to pwmchip_add().
 
> > But if Thierry agrees that this npmws (or num-pwms) is a good idea, it
> > would be great to start early to convert drivers.
> 
> Do we actually need this? It seems like Paul's patch here properly
> derives the number of available PWMs from the compatible string, so I
> don't see what the extra num-pwms (or whatever) property would add.

Given that the only difference between the two different implementations
is just the number of pwms provided, this could just be expressed in the
dts as:

	pwm@2000000 {
		compatible = "jz4740";
		num-pwms = <8>;
	}

and

	pwm@2000000 {
		compatible = "jz4740";
		num-pwms = <6>;
	}

instead of

	pwm@2000000 {
		compatible = "jz4740";
	}

and

	pwm@2000000 {
		compatible = "jz4725";
	}

. According to my metric the former is more descriptive and so better.

And then the pwm core could provide parsing of that property (e.g. if
chip.npwm == 0) which simplifies the driver (and all others using that
mechanism).

Regarding the question "Do we actually need this?": We don't, but I
think it would make a nice step to get more descriptive device trees and
so I consider it an improvement. It would also allow to check a dtb
because even without the driver you can notice that

	pwms = <&pwm 12 0>;

is invalid if &pwm has "num-pwms = <8>". Drivers that could benefit are
(at least): hibvt, sun4i, tegra, lpss.

Best regards
Uwe

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

  reply	other threads:[~2018-12-20 20:58 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-12 22:08 [PATCH v8 00/26] Ingenic TCU patchset v8 Paul Cercueil
2018-12-12 22:08 ` [PATCH v8 01/26] dt-bindings: ingenic: Add DT bindings for TCU clocks Paul Cercueil
2018-12-17 23:18   ` Stephen Boyd
2018-12-12 22:08 ` [PATCH v8 02/26] doc: Add doc for the Ingenic TCU hardware Paul Cercueil
2018-12-12 22:08 ` [PATCH v8 03/26] dt-bindings: Add doc for the Ingenic TCU drivers Paul Cercueil
2018-12-17 21:05   ` Rob Herring
2018-12-17 22:03     ` Paul Cercueil
2018-12-18 16:36       ` Rob Herring
2018-12-22 11:09         ` Paul Cercueil
2018-12-12 22:08 ` [PATCH v8 04/26] clocksource: Add a new timer-ingenic driver Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 05/26] clocksource: Add driver for the Ingenic JZ47xx OST Paul Cercueil
2019-01-23 12:58   ` Mathieu Malaterre
2019-01-23 14:31     ` Guenter Roeck
2019-01-23 17:25       ` Paul Cercueil
2019-01-23 18:01         ` Guenter Roeck
2019-01-24 19:28           ` Stephen Boyd
2019-01-24 20:46             ` Paul Cercueil
2019-01-24 22:46               ` Stephen Boyd
2019-01-24 22:53                 ` Paul Cercueil
2019-02-23  3:17                   ` Paul Cercueil
2019-02-25 18:05                     ` Stephen Boyd
2019-02-27 23:54                       ` Paul Cercueil
2019-01-23 17:27     ` Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 06/26] MAINTAINERS: Add myself as maintainer for Ingenic TCU drivers Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 07/26] watchdog: jz4740: Use WDT clock provided by TCU driver Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 08/26] watchdog: jz4740: Use regmap " Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 09/26] watchdog: jz4740: Avoid starting watchdog in set_timeout Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 10/26] watchdog: jz4740: Drop dependency on MACH_JZ47xx, use COMPILE_TEST Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 11/26] pwm: jz4740: Use regmap and clocks from TCU driver Paul Cercueil
2018-12-13  9:30   ` Uwe Kleine-König
2018-12-13 14:34     ` Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 12/26] pwm: jz4740: Allow selection of PWM channels 0 and 1 Paul Cercueil
2018-12-13  9:18   ` Uwe Kleine-König
2018-12-13 13:58     ` Paul Cercueil
2018-12-13 20:32       ` Uwe Kleine-König
2018-12-16 13:36         ` Paul Cercueil
2018-12-17  7:43           ` Uwe Kleine-König
2018-12-12 22:09 ` [PATCH v8 13/26] pwm: jz4740: Drop dependency on MACH_INGENIC, use COMPILE_TEST Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 14/26] pwm: jz4740: Remove unused devicetree compatible strings Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 15/26] pwm: jz4740: Add support for the JZ4725B Paul Cercueil
2018-12-13  9:24   ` Uwe Kleine-König
2018-12-13 14:03     ` Paul Cercueil
2018-12-13 16:18       ` Thierry Reding
2018-12-13 20:42       ` Uwe Kleine-König
2018-12-14 13:50         ` Linus Walleij
2018-12-14 14:26           ` Uwe Kleine-König
2018-12-14 14:56             ` Linus Walleij
2018-12-16 14:18             ` Paul Cercueil
2018-12-17  7:53               ` Uwe Kleine-König
2018-12-20 17:39                 ` Thierry Reding
2018-12-20 20:58                   ` Uwe Kleine-König [this message]
2018-12-12 22:09 ` [PATCH v8 16/26] clk: jz4740: Add TCU clock Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 17/26] MIPS: Kconfig: Select TCU timer driver when MACH_INGENIC is set Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 18/26] MIPS: jz4740: Add DTS nodes for the TCU drivers Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 19/26] MIPS: qi_lb60: Move PWM devices to devicetree Paul Cercueil
2018-12-12 22:09 ` [PATCH v8 20/26] MIPS: qi_lb60: Reduce system timer and clocksource to 750 kHz Paul Cercueil
2018-12-12 22:12 ` [PATCH v8 21/26] MIPS: CI20: Reduce system timer and clocksource to 3 MHz Paul Cercueil
2018-12-12 22:12 ` [PATCH v8 22/26] MIPS: CI20: defconfig: enable OST driver Paul Cercueil
2018-12-12 22:13 ` [PATCH v8 23/26] MIPS: GCW0: Move clocksource to TCU channel 2 Paul Cercueil
2018-12-12 22:13 ` [PATCH v8 24/26] MIPS: GCW0: Reduce system timer and clocksource to 750 kHz Paul Cercueil
2018-12-12 22:14 ` [PATCH v8 25/26] MIPS: GCW0: defconfig: Enable OST, watchdog, PWM drivers Paul Cercueil
2018-12-12 22:15 ` [PATCH v8 26/26] MIPS: jz4740: Drop obsolete code Paul Cercueil
2019-01-24 21:26 ` [PATCH v8 00/26] Ingenic TCU patchset v8 Mathieu Malaterre
2019-01-24 21:41   ` Paul Cercueil
2019-01-25  8:21     ` Mathieu Malaterre
2019-01-25 17:04       ` Paul Cercueil

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=20181220205809.5t2klpb7donmoibb@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=corbet@lwn.net \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=ezequiel@collabora.co.uk \
    --cc=jhogan@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=malat@debian.org \
    --cc=mark.rutland@arm.com \
    --cc=od@zcrc.me \
    --cc=paul.burton@mips.com \
    --cc=paul@crapouillou.net \
    --cc=prasannatsmkumar@gmail.com \
    --cc=ralf@linux-mips.org \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    --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).