OpenWrt Forum Archive

Topic: Bidirectional gpio in adm5120 - how to?

The content of this topic has been archived on 2 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Help please - i want use 5120 for smart home apllication - how i can use gpio on latest svn kamikaze for input in userspace?
some like a
cat /dev/gpioXX
or
cat /proc/dev/gpioxx
and how i can change gpio directional - for output or input like a
echo "input" > /dev/gpioXX
echo "output" > /dev/gpioXX
or similar...

do you actually have /dev/gpio node being created?  I'm using the latest trunk on IXP4xx boards (Avila Gateworks) more specifically and the node is not being created with the latest trunk. 

If you have it, then lucky you smile  Install the gpioctl package and you should get some control of your gpio pins.  I was just getting comfortable using them in the 2.6.23 kernels, and now they are gone sad

no - i does not have /dev/gpio
when i use gpioctl utility - they said error:

root@OpenWrt:/# gpioctl dirin 2
Error whilst opening /dev/gpio

Even when I create /dev/gpio - gpioctl does not work:

root@OpenWrt:/# mknod /dev/gpio c 167 2
root@OpenWrt:/# ls -l /dev/g*
crw-r--r--    1 root     root     167,   2 Jan  1 00:05 /dev/gpio
root@OpenWrt:/# gpioctl dirin 2
Error whilst opening /dev/gpio
root@OpenWrt:/#   

Has tried to use buttons-driver - it is loaded, but so does not work, or I simply have not understood as it to use:

oot@OpenWrt:/# lsmod
Module                  Size  Used by    Not tainted
...
gpio_buttons            2080  0
input_polldev           1584  1 gpio_buttons
...
input_core             18160  2 gpio_buttons,input_polldev
...
root@OpenWrt:/#

Can though somebody to advise in what direction to dig this question? Use adm5120 as the device for house automation interests, therefore it is necessary to receive a maximum quantity of inputs and outputs operated of userspace

House automation does not need very fast I/O
You can always, use remote I/O devices with serial or network interfaces.
If you want to use adm5120 as base of a home automation system, another option for I/O is I2C interface.
Which adm5120 device are you using ?

(Last edited by Slammer on 22 May 2008, 06:07)

Yes, it agree - very fast exchange with external devices is not necessary to me, but the idea to use additional rs232 or network devices calls into question into use most adm5120. Originally my idea consist that adm5120 represents itself as www a server by means of which there is a management and adjustment of parameters of house system, and executive devices and gauges are connected through the minimal outcome (the relay, transistor keys) to gauges (концевики, thermodes, photogauges) and on executive devices through the relay and keys.
i'm use planet xrt-401d - it's trivial adm5120 based broadband router.

I have a little more understood - the problem what platform br6104k has no in the board description (trunk/build_dir/linux-adm5120_router_le/linux-2.6.24.7/arch/mips/adm5120/platform.c) of the device for direct access to gpio but only hcd and flash - prompt in what direction to dig further?

Really nobody uses similar devices for input of the discrete information - for example for the house signal system or for calculation something...? - I have tried 2.4 all with a branch works!!!, but openwrt it is grinded under 2.6 help please...

While gpio is included in kernel, still no /dev/gpio....
Still with SVN 11667 we dont have access to gpio.
Any help?

Edit:
I didn't noticed... there is a relevant ticket : https://dev.openwrt.org/cgi-bin/trac.fcgi/ticket/3518

(Last edited by Slammer on 6 Jul 2008, 21:32)

Slammer wrote:

While gpio is included in kernel, still no /dev/gpio....
Still with SVN 11667 we dont have access to gpio.
Any help?

Edit:
I didn't noticed... there is a relevant ticket : https://dev.openwrt.org/cgi-bin/trac.fcgi/ticket/3518

I haven't looked at the latest SVN, but if GPIO is included in the kernel it is not very hard to write your
own module which allows access to GPIO (in either direction).

Some example kernel module code here:
http://linux-adm5120.svn.sourceforge.ne … io-proxy.c
http://linux-adm5120.svn.sourceforge.ne … gpio-proxy

And here is some userland code
http://linux-adm5120.svn.sourceforge.ne … pio-proxyd

...Although I suspect this does far more than what you need.

Thanks bifferos!  gpio_proxy module did the job.

Big thank's bifferos !!! gpio-proxy real cool...

Anyway, I am not using the gpio-proxyd directly.
I am using simple routines in userland (based on gpio-proxyd code) inside my program.
I can share the code if someone is interested.

Yes - i have such interest...
I can't make gpio on my device work :-( even with gpio-proxy...
i try'd gpioctl but they need char device /dev/gpio wich does not maked with my platform edimax-br6104k (planet xrt401d in real)
it's aslo have reset button connected to gpio2 and 11 Leds (2*port(5)+1*power) led's work like a sharm but button not :-(
nor gpio-button nor hotplug-buttons ...

With gpio-proxy code you can read the state on any input (like button) but there is no hotplug or event support.
You just read the state of an input with a function eg. 

input = GetInput( n )

n is the input number.

(Last edited by Slammer on 1 Aug 2008, 14:23)

gorec wrote:

Yes - i have such interest...
I can't make gpio on my device work :-( even with gpio-proxy...
i try'd gpioctl but they need char device /dev/gpio wich does not maked with my platform edimax-br6104k (planet xrt401d in real)
it's aslo have reset button connected to gpio2 and 11 Leds (2*port(5)+1*power) led's work like a sharm but button not :-(
nor gpio-button nor hotplug-buttons ...

Did you load button-hotplug module?  I haven't tried but it is supposed to generate an input event for hotplug rules.
(but only for the reset button).  Unfortunately, this is only working in polled mode.

Big thank's to juhosd!
All gpio interaction work just fine!
I'm very-very glad!!!
gpioctl via /dev/gpio char dev work ok
buttons-hotplug work too (with event mechanizm!!!)

It's enought for any automation... and smart home application...

now we just need a little wiki about this ;-)

How to load that gpio-proxy???

I have the same problem in not accessing gpio in /dev/gpio

The discussion might have continued from here.