Re: [PATCH v2 1/2] gpio: Add driver for Zynq GPIO controller

From: Linus Walleij
Date: Tue Jul 08 2014 - 05:34:41 EST

On Mon, Jul 7, 2014 at 6:08 PM, SÃren Brinkmann
<soren.brinkmann@xxxxxxxxxx> wrote:

>> So: what is the usecase for these GPIOs?
> Yea, in this case it was a button. I have to look at these drivers. It's
> very likely that they cover what I want. But this case is trivial. I
> really don't do anything but enabling the IRQ by writing to the edge
> attribute and press the push-button connected to that GPIO line.

In case of a system using device tree it is very trivial to add a gpio
key binding. After compiling in the gpio keys driver this small
snipper type is all that is really needed in most cases:

/* User key mapped in as "escape" */
gpio-keys {
compatible = "gpio-keys";
user-button {
label = "user_button";
gpios = <&gpio0 3 0x1>;
linux,code = <1>; /* KEY_ESC */

> But as a general note: I think we have quite some customers trying to do
> GPIO in userspace.

For what? I mean the use cases. Usually it is a bad idea, and
as shown above, just using the right existing device driver with
device tree is much easier, also for an end user, given they know
how to alter DTs and compile in kernel modules.

> With Zynq's FPGA portion, a lot of things come down
> to make signals accessible in Linux and a lot of people do not want or
> need a full blown kernel driver and use GPIO. The request for 'how to
> handle GPIO IRQs in userspace' is pretty common. Often this gets passed
> on to UIO though.

The short answer is don't handle GPIO IRQs in userspace.

Userspace drivers is generally a bad idea and should not be written.
The kernel is intended to handle hardware.

The above is doubly true for anything involving IRQs. Just think
of what IRQs are. They are one of the reasons why we have a
kernel and not just write all software on a system from scratch

Linus Walleij
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at