From: Alexandre Courbot <gnurou@gmail.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Stephen Warren <swarren@wwwdotorg.org>
Subject: Re: Correct meaning of the GPIO active low flag
Date: Mon, 10 Feb 2014 23:50:40 +0900 [thread overview]
Message-ID: <CAAVeFuLx7EdMRXN_f57zy=3MYrSJWk0N6MKkK+PrbAX+ivpJQg@mail.gmail.com> (raw)
In-Reply-To: <4298328.sSSAEV5F8t@avalon>
Hi Laurent,
On Mon, Feb 10, 2014 at 11:33 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
> Hello everybody,
>
> While working on Dt support for a driver that uses GPIO I came to ponder about
> the correct meaning of the GPIO active low flag. I'm bringing the question to
> the mailing list to get feedback.
>
> When a device has an active low input, the fact that the input is active low
> is a property of the device, and thus known to the driver. On the other hand,
> if an inverter is present on the board, that information isn't known to device
> drivers and need to be expressed in DT.
>
> Does the active low flag express the latter only, or both of them ? To ask the
> question differently, should the low flag model the inverter inside the
> device, known to the device driver, effectively moving handling of that
> inverter out of the device driver to the core code, or should it stop at the
> device boundary and only model the board ?
The intent behind the current behavior of the gpiod interface is to
avoid the need for code like this:
if (pb->enable_gpio_flags & PWM_BACKLIGHT_GPIO_ACTIVE_LOW)
gpio_set_value(pb->enable_gpio, 0);
else
gpio_set_value(pb->enable_gpio, 1);
which could simply be replaced by:
gpiod_set_value(pb->enable_gpio, 1);
and the GPIO framework will invert the signal if needed according to
the active low property of the GPIO.
This behavior is based on the assumption that the active low flag
represents an inverter present on the board, and thus unknown to the
device driver. Now I just hope this assumption is correct. On the
other hand I'm not sure I would understand the need for it if it were
to model a property of the device, as the driver would be aware of it
anyway, and thus should not need to be told about it explicitly.
> As an example, if my device datasheet states that the reset input is active
> low, an no inverter is present on the GPIO line, should I set the GPIO active
> low flag in DT and set the GPIO value to 1 in software (assuming I use the
> gpiod_* API) to make the reset signal active, or should I set the GPIO active
> high flag in DT and the the GPIO value to 0 in software ?
If your datasheet explicitly states that the reset input is active
low, then this fact should be captured by the compatible property
already (since the active low status is true for each and every
compatible device) and I don't think your node would need to state it
in addition. Unless, of course, there is an inverter on the way.
This is my understanding but let's see what others have to say and
let's also make sure to update the documentation to lift the
ambiguity. :)
Alex.
next prev parent reply other threads:[~2014-02-10 14:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-10 14:33 Correct meaning of the GPIO active low flag Laurent Pinchart
2014-02-10 14:50 ` Alexandre Courbot [this message]
2014-02-10 15:13 ` Laurent Pinchart
2014-02-10 16:56 ` Stephen Warren
2014-02-10 16:57 ` Stephen Warren
2014-02-10 17:52 ` Laurent Pinchart
2014-02-10 23:04 ` Stephen Warren
2014-02-10 23:21 ` Laurent Pinchart
2014-02-12 16:50 ` Stephen Warren
2014-02-13 14:43 ` Laurent Pinchart
2014-02-13 16:49 ` Stephen Warren
2014-02-14 23:48 ` Laurent Pinchart
2014-02-15 0:07 ` Stephen Warren
2014-02-15 0:20 ` Laurent Pinchart
2014-02-18 17:58 ` Stephen Warren
2014-02-19 0:19 ` Laurent Pinchart
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='CAAVeFuLx7EdMRXN_f57zy=3MYrSJWk0N6MKkK+PrbAX+ivpJQg@mail.gmail.com' \
--to=gnurou@gmail.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=swarren@wwwdotorg.org \
/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).