<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/3/29 Sven Geggus <span dir="ltr">&lt;<a href="mailto:lists@fuchsschwanzdomain.de" target="_blank">lists@fuchsschwanzdomain.de</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hello,<br>
<br>
I have a userland application on Raspberry Pi which uses select to read<br>
input from a button connected to gpio like this:<br>
<br>
GPIO --+---- BUTTON ----- GND<br>
       |<br>
       +--- RESISTOR 2k -- VCC (3.3V)<br>
<br>
The sysfs &quot;file&quot; I use select at is /sys/class/gpio/gpioX/value with the<br>
method found in Documentation/gpio.txt.<br>
<br>
However, this same file also states the following:<br>
Note that standard kernel drivers exist for common &quot;LEDs and Buttons&quot;<br>
GPIO tasks:  &quot;leds-gpio&quot; and &quot;gpio_keys&quot;, respectively.  Use those<br>
instead of talking directly to the GPIOs; they integrate with kernel<br>
frameworks better than your userspace code could.<br>
<br>
So how can I make this &quot;standard kernel drivers&quot; work?<br>
<br>
I would like to get rid of using /sys/class/gpio/gpioX/value and use<br>
/dev/input/eventX instead, because the first method will require debouncing<br>
in userland and is not portable to other keyboard types.<br>
<br>
I tried to compile a kernel with CONFIG_KEYBOARD_GPIO enabled and load<br>
gpio_keys.ko. However this did neither create a new device in /dev/input/<br>
nor /sys/devices/platform/gpio-keys.<br></blockquote><div><br></div><div style>The entry will only be created after the &quot;Driver&quot; probes the &quot;Device&quot; successfully. In your case, you need to be sure the corresponding platform_device is claimed in your board setup code. The setup logic vary from Arch/mach to Arch/mach. Here is one example from sh.</div>
<div style><br></div><div style><a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c">http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c</a><br></div><div style><br></div><div style>
<pre class="" id="e5/7f/6006ed531886aecec211911870f46c9bcc8b_3/0" style="margin-top:0px;margin-bottom:0px;padding-top:0px;padding-bottom:0px;color:rgb(0,0,0)"><a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L199" id="L199" class="" name="L199" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 199</a>static struct <a href="http://lxr.linux.no/linux+v3.4.11/+code=gpio_keys_platform_data" class="">gpio_keys_platform_data</a> <a href="http://lxr.linux.no/linux+v3.4.11/+code=baseboard_buttons_data" class="">baseboard_buttons_data</a> = {
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L200" id="L200" class="" name="L200" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 200</a>        .<a href="http://lxr.linux.no/linux+v3.4.11/+code=buttons" class="">buttons</a>        = <a href="http://lxr.linux.no/linux+v3.4.11/+code=baseboard_buttons" class="">baseboard_buttons</a>,
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L201" id="L201" class="" name="L201" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 201</a>        .<a href="http://lxr.linux.no/linux+v3.4.11/+code=nbuttons" class="">nbuttons</a>       = <a href="http://lxr.linux.no/linux+v3.4.11/+code=ARRAY_SIZE" class="">ARRAY_SIZE</a>(<a href="http://lxr.linux.no/linux+v3.4.11/+code=baseboard_buttons" class="">baseboard_buttons</a>),
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L202" id="L202" class="" name="L202" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 202</a>};
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L203" id="L203" class="" name="L203" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 203</a>
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L204" id="L204" class="" name="L204" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 204</a>static struct <a href="http://lxr.linux.no/linux+v3.4.11/+code=platform_device" class="">platform_device</a> <a href="http://lxr.linux.no/linux+v3.4.11/+code=baseboard_buttons_device" class="">baseboard_buttons_device</a> = {
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L205" id="L205" class="" name="L205" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 205</a>        .<a href="http://lxr.linux.no/linux+v3.4.11/+code=name" class="">name</a>           = <span class="" style="font-style:italic;color:green">&quot;gpio-keys&quot;</span>,
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L206" id="L206" class="" name="L206" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 206</a>        .<a href="http://lxr.linux.no/linux+v3.4.11/+code=id" class="">id</a>             = -1,
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L207" id="L207" class="" name="L207" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 207</a>        .<a href="http://lxr.linux.no/linux+v3.4.11/+code=dev" class="">dev</a>            = {
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L208" id="L208" class="" name="L208" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 208</a>                .<a href="http://lxr.linux.no/linux+v3.4.11/+code=platform_data" class="">platform_data</a>  = &amp;<a href="http://lxr.linux.no/linux+v3.4.11/+code=baseboard_buttons_data" class="">baseboard_buttons_data</a>,
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L209" id="L209" class="" name="L209" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 209</a>        },
<a href="http://lxr.linux.no/linux+v3.4.11/arch/sh/boards/mach-x3proto/setup.c#L210" id="L210" class="" name="L210" style="border:1px solid rgb(0,0,0);margin-left:0px;margin-right:7px;padding-left:3px;padding-right:3px;background-color:rgb(240,240,240)"> 210</a>};</pre>
</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Kconfig states the following:<br>
...<br>
Your board-specific setup logic must also provide a platform device,<br>
with configuration data saying which GPIOs are used.<br>
...<br>
<br>
So looks like my &quot;board-specific setup logic&quot; (whatever this might be) does<br>
not &quot;provide a platform device with configuration data saying which GPIOs<br>
are used&quot;.<br>
<br>
So my question is twofold:<br>
1. Where can I find the &quot;board-specific setup logic&quot; (for Rapberry Pi in my<br>
case<br>
2. How would this &quot;board-specific setup logic&quot; (if unavailable) look like to<br>
make gpio_keys.ko work?<br>
<br>
Sven<br>
<br>
P.S.: The kernel in use is the one from<br>
git://<a href="http://github.com/raspberrypi/linux.git" target="_blank">github.com/raspberrypi/linux.git</a> which is basically a vanilla 3.6.11<br>
with Raspberry Pi specific patches.<br>
<span class=""><font color="#888888"><br>
--<br>
Threading is a performance hack.<br>
(The Art of Unix Programming by Eric S. Raymond)<br>
<br>
/me is giggls@ircnet, <a href="http://sven.gegg.us/" target="_blank">http://sven.gegg.us/</a> on the Web<br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</font></span></blockquote></div><br></div></div>