linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* More GPIO madness on iMX6 - and the crappy ARM port of Linux
@ 2014-01-17 18:47 Russell King - ARM Linux
  2014-01-17 19:13 ` Eric Nelson
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Russell King - ARM Linux @ 2014-01-17 18:47 UTC (permalink / raw)
  To: linux-arm-kernel

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.

However, what about the behaviour of GPIOs?

What about... for example... this sequence:

	gpio_direction_output(gpio, 1);
	val = gpio_get_value(gpio);

What value is "val"?  More importantly, what value is reflected in
/sys/kernel/debug/gpio ?  Would it indicate that it's high or low?

Now, while you can make reasonable assumptions, such as "it'll return
that the output is being driven to the requested state" or "it'll
return the actual state of the pin", what about this instead, which
happens on iMX hardware - "it'll _always_ return zero".

Yes, iMX6 at least has this behaviour.  For any output, val as above
will always be zero, and /proc/sys/kernel/debug/gpio will always
report that an output is zero... unless the SION bit has been set for
that GPIO signal.

The reason is that on hardware such as iMX6, reading the GPIO is done
by reading the pad state register, and this register is _only_ supplied
the state of the pad when the input path is enabled.  The input path
is only enabled when the output is disabled, or the SION bit is set
to force the GPIO input path.

So, this brings up three obvious questions:

1. What should gpio_get_value() return for an output?
2. What should be reported in /sys/kernel/debug/gpio for an output?
3. Should iMX6 (and similar) GPIOs always have the SION bit set in
   their DT descriptions?

Discuss.

Since I've wasted all afternoon trying to chase down why the GPIOs
controlling the regulators for USB appear to be disabled when reading
/sys/kernel/debug/gpio, I'm *FAR* from impressed by the current
confusing behaviour - and it's another nail in the "why the ARM Linux
kernel is turning to shit" coffin.  I'm pleased to know that according
to google+, I'm not the only one with these feelings - so it's about
time we started fixing some of these idiotic and crap behaviours in
these layers of subsystems which make platform support unnecessarily
difficult.

-- 
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".

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-01-21  9:26 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).