All of lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Alexandre Courbot <gnurou@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Benoit Parrot <bparrot@ti.com>,
	Pantelis Antoniou <panto@antoniou-consulting.com>,
	Jiri Prchal <jiri.prchal@aksignal.cz>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Subject: Re: [Patch v2 1/2] gpio: add GPIO hogging mechanism
Date: Mon, 8 Dec 2014 20:18:43 +0100	[thread overview]
Message-ID: <20141208191843.GI8739@lukather> (raw)
In-Reply-To: <CAAVeFuL2CYtcDnwnuWD5wfMLGK-GEwBA09BXkhBMFJCjr2rEcg@mail.gmail.com>

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

On Sat, Dec 06, 2014 at 09:08:36PM +0900, Alexandre Courbot wrote:
> On Fri, Dec 5, 2014 at 7:24 PM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > On Thu, Dec 04, 2014 at 11:49:19PM +0900, Alexandre Courbot wrote:
> >> On Thu, Dec 4, 2014 at 11:27 PM, Maxime Ripard
> >> <maxime.ripard@free-electrons.com> wrote:
> >> > Hi,
> >> >
> >> > On Thu, Dec 04, 2014 at 11:15:38PM +0900, Alexandre Courbot wrote:
> >> >> On Wed, Dec 3, 2014 at 1:12 AM, Maxime Ripard
> >> >> <maxime.ripard@free-electrons.com> wrote:
> >> >> > On Tue, Dec 02, 2014 at 03:29:46PM +0100, Linus Walleij wrote:
> >> >> >> On Tue, Dec 2, 2014 at 3:13 PM, Alexandre Courbot <gnurou@gmail.com> wrote:
> >> >> >> > On Tue, Dec 2, 2014 at 1:36 AM, Maxime Ripard
> >> >> >> > <maxime.ripard@free-electrons.com> wrote:
> >> >> >>
> >> >> >> >> The only thing I'd like to have would be that the request here would
> >> >> >> >> be non-exclusive, so that a later driver would still be allowed later
> >> >> >> >> on to request that GPIO later on and manage it itself (ideally using
> >> >> >> >> the usual gpiod_request function).
> >> >> >> >
> >> >> >> > Actually we have a plan (and I have some code too) to allow multiple
> >> >> >> > consumers per GPIO. Although like Benoit I wonder why you would want
> >> >> >> > to hog a GPIO and then request it properly later. Also, that probably
> >> >> >> > means we should abandon the hog since it actively drives the line and
> >> >> >> > would interfere with the late requested. How to do that correctly is
> >> >> >> > not really clear to me.
> >> >> >>
> >> >> >> I don't get the usecase. A hogged GPIO is per definition hogged.
> >> >> >> This sounds more like "initial settings" or something, which is another
> >> >> >> usecase altogether.
> >> >> >
> >> >> > We do have one board where we have a pin (let's say GPIO14 of the bank
> >> >> > A) that enables a regulator that will provide VCC the bank B.
> >> >> >
> >> >> > Now, both banks are handled by the same driver, but in order to have a
> >> >> > working output on the bank B, we do need to set GPIO14 as soon as
> >> >> > we're probed.
> >> >> >
> >> >> > Just relying on the usual deferred probing introduces a circular
> >> >> > dependency between the gpio-regulator that needs to grab its GPIO from
> >> >> > a driver not there yet, and the gpio driver that needs to enable its
> >> >> > gpio-regulator.
> >> >>
> >> >> I don't get it. According to what you said, the following order should
> >> >> go through IIUC:
> >> >>
> >> >> 1) bank A is probed, gpio 14 is available
> >> >> 2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
> >> >> 3) bank B is probed, grabs its regulator and turn it on, probes.
> >> >>
> >> >> What am I missing?
> >> >
> >> > It would be true if bank A and B were exposed through different
> >> > drivers (or at least different instances of the same driver), which is
> >> > not the case.
> >> >
> >> > In our case, banks A and B are handled by the same instance.
> >>
> >> Ok, so both banks A and B are part of the same device/DT node. Now I
> >> think I understand the issue. You need to hog the pin so that bank B
> >> will work right after the device is probed.
> >
> > Exactly.
> >
> >> But you will still have the problem that the regulator device will
> >> *not* be available when your device is probed, so you cannot call
> >> regulator_get() for bank B anyway. I guess your only choice is to hog
> >> that pin and leave it active ad vitam eternam.
> >
> > Hmmm, indeed.
> >
> > I'll stop boring you with this then :)
> 
> Please *keep* bothering us with any doubt you may have until they are
> all cleared and you are sure this feature will be useful to you.
> Especially since we are designing DT bindings that will have to be
> carried over forever. We really want to get them right, and need input
> of potential users for that.
> 
> Having a few design arguments is a small thing compared to the hassle
> of having to work with unadapted features and bindings.

Ok. What I had in mind when I first thought about it was to set GPIO
as hogged through the GPIO flags, and then have a dumb GPIO driver
like Pantelis was suggesting.

I don't know if hogged would still be the right term, but we could
have that flag that would just allow the value to be set through
gpio_request init value, and deny/cache any subsequent change through
gpio_set_value.

gpio_request with this flag would never return EPROBE_DEFER, and just
cache the value to be set for when the driver comes in.

We could enforce driver-less GPIOs through that dumb driver, and we
would still be able to break weird dependency chains that end up in
circle.

That's just a thought though.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

  reply	other threads:[~2014-12-08 19:20 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 23:54 [Patch v2 0/2] gpio: add GPIO hogging mechanism Benoit Parrot
2014-11-20 23:54 ` Benoit Parrot
2014-11-20 23:54 ` [Patch v2 1/2] " Benoit Parrot
2014-11-20 23:54   ` Benoit Parrot
2014-11-28  7:30   ` Alexandre Courbot
2014-12-01 16:36     ` Maxime Ripard
2014-12-02  0:27       ` Benoit Parrot
2014-12-02 14:13       ` Alexandre Courbot
2014-12-02 14:29         ` Linus Walleij
2014-12-02 16:12           ` Maxime Ripard
2014-12-04 14:15             ` Alexandre Courbot
     [not found]               ` <CAAVeFu+Gms6ptyK6j1Zy_wWg+9URs+9zBu=pOiwiEERO=8NjNw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-04 14:27                 ` Pantelis Antoniou
2014-12-04 14:27                   ` Pantelis Antoniou
2014-12-04 14:41                   ` Alexandre Courbot
2014-12-04 14:47                     ` Pantelis Antoniou
2014-12-04 14:47                       ` Pantelis Antoniou
     [not found]                       ` <C9DBE2F0-A725-4D05-BEC6-F083F3F83B9F-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2014-12-04 14:58                         ` Alexandre Courbot
2014-12-04 14:58                           ` Alexandre Courbot
2014-12-04 15:02                           ` Pantelis Antoniou
2014-12-04 15:02                             ` Pantelis Antoniou
2014-12-04 15:10                             ` Alexandre Courbot
2014-12-04 15:22                               ` Pantelis Antoniou
2014-12-04 15:22                                 ` Pantelis Antoniou
     [not found]                                 ` <8717617A-56AE-495C-B873-0B2E3EA83060-wVdstyuyKrO8r51toPun2/C9HSW9iNxf@public.gmane.org>
2014-12-06 12:04                                   ` Alexandre Courbot
2014-12-06 12:04                                     ` Alexandre Courbot
2014-12-04 14:27               ` Maxime Ripard
2014-12-04 14:49                 ` Alexandre Courbot
2014-12-05 10:24                   ` Maxime Ripard
2014-12-06 12:08                     ` Alexandre Courbot
2014-12-08 19:18                       ` Maxime Ripard [this message]
2014-12-04 14:52               ` Maxime Ripard
2014-12-04 15:00                 ` Alexandre Courbot
2015-01-12  9:40             ` Linus Walleij
2015-01-12 12:45               ` Mark Brown
2014-12-02  0:22     ` Benoit Parrot
     [not found]       ` <20141202002244.GB24551-l0cyMroinI0@public.gmane.org>
2014-12-02 14:10         ` Alexandre Courbot
2014-12-02 14:10           ` Alexandre Courbot
     [not found]           ` <CAAVeFuJWPvdmO_KPXP2LrkAy4SQDZ+f7pvE6U8r7gPH+jE3Lrw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-02 14:28             ` Linus Walleij
2014-12-02 14:28               ` Linus Walleij
2014-12-02 14:25         ` Linus Walleij
2014-12-02 14:25           ` Linus Walleij
2014-11-20 23:54 ` [Patch v2 2/2] gpio: Document " Benoit Parrot
2014-11-20 23:54   ` Benoit Parrot
     [not found]   ` <1416527684-19017-3-git-send-email-bparrot-l0cyMroinI0@public.gmane.org>
2014-11-28  7:31     ` Alexandre Courbot
2014-11-28  7:31       ` Alexandre Courbot
2014-12-01 22:57       ` Benoit Parrot
2014-12-02 14:04         ` Alexandre Courbot

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=20141208191843.GI8739@lukather \
    --to=maxime.ripard@free-electrons.com \
    --cc=bparrot@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=gnurou@gmail.com \
    --cc=jiri.prchal@aksignal.cz \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=panto@antoniou-consulting.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.