Hi Linus, On Tue, 2014-07-08 at 11:34AM +0200, Linus Walleij wrote: > 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 */ > gpio-key,wakeup; > }; > }; Thanks for the example. I think for my cases these drivers are exactly the right thing. > > > > 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 > ourselves. I fully agree and you don't have to convince me. But to a lot of our customers that are used to use FPGAs, SOCs and Linux are pretty new. You see a lot of scary stuff. Accessing /dev/mem seems to be a lot of people's big hammer solution for everything. Then I always perceive it as great progress if things like the sysfs interface are used instead. Thanks, Sören -- To unsubscribe from this list: send the line "unsubscribe linux-doc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html