From: Trent Piepho <tpiepho@kymetacorp.com>
To: "nikita.yoush@cogentembedded.com" <nikita.yoush@cogentembedded.com>
Cc: "andrew.smirnov@gmail.com" <andrew.smirnov@gmail.com>,
"barebox@lists.infradead.org" <barebox@lists.infradead.org>,
"cphealy@gmail.com" <cphealy@gmail.com>
Subject: Re: [PATCH 2/4] gpiolib: Add code to support "active low" GPIOs
Date: Wed, 24 May 2017 18:16:19 +0000 [thread overview]
Message-ID: <1495649778.5146.219.camel@kymetacorp.com> (raw)
In-Reply-To: <db78852f-c295-d85b-1c38-3c31f2442d5f@cogentembedded.com>
On Wed, 2017-05-24 at 10:26 +0300, Nikita Yushchenko wrote:
> First point is that words "active high" (or "active low") have very
> clear meaning. And situation when chip's signal is active low, but one
> has to write "active high" in signal definition to make things working,
> is not something I welcome in systems I deal with.
>
> Second point is that by cleaning up the above, you make drivers depend
> on correct polarity settings in dts. Which means that when writing dts,
> you get need to dig over datasheets (which may be under NDA) to find out
> polarity of each signal. This looks like breakage of information
> locality - knowledge of chip's signals polarity belongs to chip's
> driver. Common case of signals connected directly to gpio providers
> should just work. It's nice to have a way to override driver's default,
I agree with this. It's pretty much random if a given signal will want
a high value to mean asserted or not. And plenty of signals switch
"modes" and it's not even clear which mode should be considered
"asserted". If drivers expect me to put active low/high in the
bindings, then it means for every signal one must get the datasheet and
figure out what a high signal means. And then likely look though the
driver code to make sure the driver sets 1 to mean that.
In cases where the polarity is arbitrary, it should be documented in the
bindings (like I did for the gpio leds binding) that one is expected to
provide the polarity.
The reason gpiolib doesn't naively handle polarity in gpio_set_value()
is because of speed. Originally gpio_set_value() was an arch specific
inline function that could check if the numeric gpio number was in the
range reserved for on-SoC gpio lines (__builtin_constant_p() lets you do
that at compile time). If so, the inline function could expand directly
to the code for setting the gpio, which could be just a single machine
instruction. You lose that speed if you need to look up a gpio
descriptor and a driver state struct and check a bunch of flags and
acquire a spinlock.
This doesn't work anymore since even built in gpios use the Linux driver
model and dynamically allocate their IDs.
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2017-05-24 18:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-22 15:24 [PATCH 1/4] gpio-imx: Do not use gpio_set_value() Andrey Smirnov
2017-05-22 15:24 ` [PATCH 2/4] gpiolib: Add code to support "active low" GPIOs Andrey Smirnov
2017-05-23 6:30 ` Nikita Yushchenko
2017-05-23 8:33 ` Sascha Hauer
2017-05-24 0:16 ` Andrey Smirnov
2017-05-24 0:14 ` Andrey Smirnov
2017-05-24 7:26 ` Nikita Yushchenko
2017-05-24 18:16 ` Trent Piepho [this message]
2017-05-24 20:36 ` Andrey Smirnov
2017-05-25 6:36 ` Nikita Yushchenko
2017-05-25 17:10 ` Andrey Smirnov
2017-05-25 17:45 ` Sascha Hauer
2017-05-22 15:24 ` [PATCH 3/4] gpiolib: Add support for GPIO "hog" nodes Andrey Smirnov
2017-05-23 6:52 ` Nikita Yushchenko
2017-05-23 23:25 ` Andrey Smirnov
2017-05-24 6:43 ` Nikita Yushchenko
2017-05-30 14:38 ` Andrey Smirnov
2017-05-24 7:26 ` Sascha Hauer
2017-05-22 15:24 ` [PATCH 4/4] usb-nop-xceiv: Add support for 'reset-gpios' binding Andrey Smirnov
2017-05-23 6:55 ` Nikita Yushchenko
2017-05-24 0:17 ` Andrey Smirnov
2017-05-23 6:08 ` [PATCH 1/4] gpio-imx: Do not use gpio_set_value() Nikita Yushchenko
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=1495649778.5146.219.camel@kymetacorp.com \
--to=tpiepho@kymetacorp.com \
--cc=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=cphealy@gmail.com \
--cc=nikita.yoush@cogentembedded.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