linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: More GPIO madness on iMX6 - and the crappy ARM port of Linux
Date: Fri, 17 Jan 2014 20:53:46 +0000	[thread overview]
Message-ID: <20140117205346.GH15937@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <52D995C4.80104@wwwdotorg.org>

On Fri, Jan 17, 2014 at 01:42:44PM -0700, Stephen Warren wrote:
> On 01/17/2014 01:24 PM, Russell King - ARM Linux wrote:
> > On Fri, Jan 17, 2014 at 12:40:02PM -0700, Stephen Warren wrote:
> >> On 01/17/2014 11:47 AM, Russell King - ARM Linux wrote:
> >>> So, we have this wonderful GPIO layer which abstracts GPIO stuff and
> >>> hides stuff.  It's really wonderful, because you don't have to care
> >>> about how the GPIOs are actually accessed in drivers anymore.
> >> ...
> >>> 1. What should gpio_get_value() return for an output?
> >>
> >> Some HW can't ever read back the value of an output pin, so isn't
> >> calling gpio_get_value() undefined for output pins?
> > 
> > As has been pointed out, that's not how gpio_get_valie() is documented.
> > It's documented to return the value of the pin where possible.  In my
> > case, it _is_ possible to read back the value of the pin - it just
> > needs the appropriate chip configuration to make it happen.
> > 
> > Now to the crunch point of my email: where subsystems differ completely
> > _unnecessarily_ from what is expected from them - such as returning the
> > current state of the output where it's possible to do so - then this
> > kind of difference *reduces* the portability of that subsystem, and
> > makes being able to move from one SoC to another _unnecessarily_ more
> > difficult.
> 
> If the gpio_get_value() was guaranteed never to be valid for an output
> pin, that would actually be *more* portable, not less; it would work the
> same way everywhere.
> 
> I believe you want gpio_get_value() to return either the driven or
> actual pin value where it can on the current HW, but just e.g. hard-code
> 0 on other HW. That would introduce a core feature that works some
> places but not others, and hence make drivers that relied on the feature
> less portable between HW with different actual features.

I can buy that argument, but there's an issue which stands squarely in
its way, and that is open-drain GPIOs.

These are modelled just as any other GPIO, mainly so that both
gpio_set_value(gpio, 1) and gpio_direction_input(gpio) both result in
the signal being high.  The only combination which results in the
signal being driven low is outputting zero - and the state of the signal
can aways be read back.

The problem here is that such gpios are implemented in things like the
I2C driver such that they're _always_ outputs, and gpio_set_value() is
used to pull the signal down.  gpio_get_value() is used to read its
current state.

So, if we say that gpio_get_value() is undefined, we force such
subsystems to always jump through the non-open-drain paths (using
gpio_direction_input() to set the line high and
gpio_direction_output(gpio, 0) to drive it low.)

-- 
FTTC broadband for 0.8mile line: 5.8Mbps down 500kbps up.  Estimation
in database were 13.1 to 19Mbit for a good line, about 7.5+ for a bad.
Estimate before purchase was "up to 13.2Mbit".

  reply	other threads:[~2014-01-17 20:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17 18:47 More GPIO madness on iMX6 - and the crappy ARM port of Linux Russell King - ARM Linux
2014-01-17 19:13 ` Eric Nelson
2014-01-17 19:33   ` Eric Nelson
2014-01-17 19:40 ` Stephen Warren
2014-01-17 20:20   ` Uwe Kleine-König
2014-01-17 20:43     ` Russell King - ARM Linux
2014-01-17 21:53       ` Linus Walleij
2014-01-17 23:09     ` Eric Nelson
2014-01-17 20:24   ` Russell King - ARM Linux
2014-01-17 20:42     ` Stephen Warren
2014-01-17 20:53       ` Russell King - ARM Linux [this message]
2014-01-17 22:43         ` Linus Walleij
2014-01-21  2:55           ` Alexandre Courbot
2014-01-21  7:11             ` Lothar Waßmann
2014-01-21  9:26             ` Linus Walleij
2014-01-17 19:57 ` Arnaud Patard (Rtp)
2014-01-17 20:12   ` Eric Nelson
2014-01-17 20:33     ` Arnaud Patard (Rtp)
2014-01-17 22:02       ` Eric Nelson

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=20140117205346.GH15937@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.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).