linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Rob Herring <robh@kernel.org>
Cc: Oleksij Rempel <o.rempel@pengutronix.de>,
	William Breathitt Gray <vilhelm.gray@gmail.com>,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
	<devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	David Jander <david@protonic.nl>,
	Robin van der Gracht <robin@protonic.nl>,
	linux-iio <linux-iio@vger.kernel.org>,
	Jonathan Cameron <jic23@kernel.org>
Subject: Re: [PATCH v5 1/2] dt-bindings: counter: add event-counter binding
Date: Fri, 12 Feb 2021 10:22:46 +0100	[thread overview]
Message-ID: <CACRpkdYLH-D84BinPNvhw2YDvRp=KMeBLqWYhyJQBh+hGFB9Dg@mail.gmail.com> (raw)
In-Reply-To: <20210210184138.GA2504266@robh.at.kernel.org>

On Wed, Feb 10, 2021 at 7:41 PM Rob Herring <robh@kernel.org> wrote:
> On Mon, Feb 08, 2021 at 02:53:46PM +0100, Oleksij Rempel wrote:

> > +  interrupts:
> > +    maxItems: 1
> > +
> > +  gpios:
> > +    description: Optional diagnostic interface to measure signal level
>
> This description seems wrong in the case of only having a GPIO.
>
> Also, a GPIO only implies polled mode because if the GPIO is interrupt
> capable, 'interrupts' should be required. For gpio-keys, we split the
> compatible strings in this case. I leave it to you if you want to make
> it more explicit.

Ouch. This is a bit of semantic confusion where I see different things
if I put my Linux hat on than if I put my DT hat on ... :/

Linux (or some other OS I suppose) has the ability to look up an
interrupt resource for a GPIO line and that is used quite extensively.

In this case it is certainly possible to write a Linux driver that only take
a GPIO resource and looks up a corresponding interrupt without the
involvement of any DT interrupt resources. This happens a lot.

A typical example is cd-gpios in
Documentation/devicetree/bindings/mmc/mmc-controller.yaml

The operating system will take cd-gpios and infer the corresponding
IRQ from the GPIO hardware by OS-internal mechanisms (in the Linux
case simply using irqdomain) in almost cases, and that is how that is
used today. It is an hardware interrupt
that gets allocated and used but the DT is blissfully ignorant about.

The reason is that GPIO is "general purpose" so they don't have very
specific use cases and the interrupts are general purpose as well.
A certain GPIO line may not even have a certain interrupt associated
with it: there exist GPIO controllers with e.g. 32 GPIO lines but
only 8 interrupts that can be assigned to GPIO lines on a
first-come-first-serve basis so there could not be anything like
a cell in the bindings pointing to a certain interrupt: it has to be
resolved by software, at runtime.

In many cases the corresponsing GPIO hardware will have both
gpio-controller and interrupt-controller flags, but I bet there exist
cases that are only flagged with gpio-controller and then the drivers
in the OS goes and implement interrupts using its abstractions and
assign them anyway.

I don't know if this can be solved in a generic way (solved as in DT
needs to know all about the systems interrupt resources, and the OS
should not be handing out interrupts behind the back of the DT description
for things that are not flagged as interrupt-controller) or if this ambiguity
around GPIO chips just has to stay around forever.

I think it may be one of those cases where DT bindings can't be
all that imperialistic about controlling every resource, but there may
be other views on this.

Yours,
Linus Walleij

  reply	other threads:[~2021-02-12  9:24 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08 13:53 [PATCH v5 0/2] add support for GPIO or IRQ based evemt counter Oleksij Rempel
2021-02-08 13:53 ` [PATCH v5 1/2] dt-bindings: counter: add event-counter binding Oleksij Rempel
2021-02-10 18:41   ` Rob Herring
2021-02-12  9:22     ` Linus Walleij [this message]
2021-02-12  9:29   ` Linus Walleij
2021-02-08 13:53 ` [PATCH v5 2/2] counter: add IRQ or GPIO based event counter Oleksij Rempel
2021-02-08 14:14   ` William Breathitt Gray
2021-02-12  9:26   ` Linus Walleij
2021-02-15  7:58     ` Oleksij Rempel
2021-02-14  8:54   ` William Breathitt Gray
2021-02-15  9:17     ` Oleksij Rempel
2021-02-22  1:43       ` William Breathitt Gray
2021-02-23 10:06         ` Oleksij Rempel
2021-02-23 17:45           ` Oleksij Rempel
2021-02-24  2:34             ` William Breathitt Gray
2021-02-24  7:35               ` Oleksij Rempel
2021-02-24  8:11                 ` William Breathitt Gray
2021-02-24  8:20                   ` William Breathitt Gray
2021-02-26  6:46                     ` Oleksij Rempel
2021-02-26  6:58                       ` William Breathitt Gray
2021-03-02 15:37               ` Linus Walleij
2021-02-14  7:43 ` [PATCH v5 0/2] add support for GPIO or IRQ based evemt counter William Breathitt Gray

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='CACRpkdYLH-D84BinPNvhw2YDvRp=KMeBLqWYhyJQBh+hGFB9Dg@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=david@protonic.nl \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=robin@protonic.nl \
    --cc=vilhelm.gray@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).