linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Rob Herring <robh+dt@kernel.org>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
	Kent Gibson <warthog618@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Drew Fustini <dfustini@baylibre.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] gpiolib: TODO: add an item about GPIO safe-state
Date: Fri, 16 Sep 2022 16:00:33 +0200	[thread overview]
Message-ID: <CACRpkdZSi4DiqNShPB8YkhbDdYG7=yRRXXaiZFptHT2fdEOwqw@mail.gmail.com> (raw)
In-Reply-To: <CAL_JsqKxdX_Pya-N9n+w8a9ZqCa3AdFaRUXu0E31Joyb0psk_w@mail.gmail.com>

On Fri, Sep 16, 2022 at 3:47 PM Rob Herring <robh+dt@kernel.org> wrote:

> > Inability to drive through a DT binding that was acceptable for the
> > DT binding maintainers.
>
> AFAICT, this came up briefly in 2015, then 2017, then 2019. (You're a
> year late this time.) A nice regular pattern to not get something
> upstream...

:D

> > A good idea to get it passed I think would be to ask Rob (with some
> > examples) how he thinks it should look and finalize the bindings
> > before coding.
>
> My issue was more that by the time the kernel or even bootloader runs,
> quite a bit of time has passed given all the firmware that runs
> nowadays. Doesn't a safe state need to be set as early as possible?
> Like probably before anything using DT?

So that is less related to the bindings and more related to the
implementation, right?

I think this has always been seen as "default state at the point
when the operating system boots" but possibly we should just add
a flag or something to the bindings to say how early-ish the
particular default safe state config applies?

> A node per GPIO could end up being a lot of nodes and I can certainly
> see folks just initializing every GPIO. That would be a lot of bloat.
> As I see it we need 4 bits per line: direction, state(high/low), pull
> up/down/none.

I don't know exactly which use cases people have here, but yeah
definitely biasing for example, so a certain line can go out of reset
thanks to getting pulled up.

I imagined something like a ngpios long array:

/* Initial states */
gpio-init-states = <GPIO_OUT_LOW, GPIO_OUT_HIGH,
  GPIO_NO_CHANGE, GPIO_NO_CHANGE, GPIO_OUT_HIGH ...>;

these defines does not exist in include/dt-bindings/gpio/gpio.h,
it's just my idea of it.

> Finally, don't non-GPIO pins need the same thing? You don't want a
> default output driving what needs to be an input.

The pin control subsystem has something like this, in the "default"
and "init" states the pins are set to a default mux/pin config.
So for SoC GPIOs in many cases this problem is already solved
by using pin control states and hogs, as pin control is often used
as a back-end for GPIO. e.g. all Qualcomm platforms TLMM.

GPIO lines however can also be on a I2C or USB expander or
something where pin control is not applicable at all, so this would be
for initializing lines on those controllers.

Yours,
Linus Walleij

      reply	other threads:[~2022-09-16 14:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 15:11 [PATCH] gpiolib: TODO: add an item about GPIO safe-state Bartosz Golaszewski
2022-09-14 15:20 ` Geert Uytterhoeven
2022-09-14 15:22   ` Bartosz Golaszewski
2022-09-14 16:21 ` Kent Gibson
2022-09-14 16:25   ` Bartosz Golaszewski
2022-09-14 16:42     ` Kent Gibson
2022-09-15  7:44       ` Bartosz Golaszewski
2022-09-15  8:58 ` Linus Walleij
2022-09-16  7:11   ` Bartosz Golaszewski
2022-09-16 13:12     ` Linus Walleij
2022-09-16 13:47       ` Rob Herring
2022-09-16 14:00         ` Linus Walleij [this message]

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='CACRpkdZSi4DiqNShPB8YkhbDdYG7=yRRXXaiZFptHT2fdEOwqw@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=brgl@bgdev.pl \
    --cc=dfustini@baylibre.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marek.vasut@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=warthog618@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).