Topic: Simple GPIO on the Infocast 8

After perusing the blog post at http://www.bunniestudios.com/blog/?p=1140 and a few other places, I've been able to turn on GP49 GP54 and GP55 (via regutil -w GPIO2_PSR=0x00c20000).  However, I don't know how to access them individually.

However, I would like to be able to control these three individually.  I know next to nothing about GPIO, and just want to drive some LEDs... what parameters would I need to pass to regutil to turn on/off only one GPIO at a time?  Also, are there any other pins available that could function as GPIO (e.g. on the JTAG or serial connectors), and how would I access them?

Finally, is there any way for me to adjust the output on the GPIO pins, or is it strictly digital?

Thanks!

Re: Simple GPIO on the Infocast 8

Digging up old threads in my attempts to get GPIO working via the sysfs filesystem and I think I know the answer to the first question about addressing them individually.

If you take 0x00c20000 and turn it binary, you'll get this:
0000 0000 1100 0010 0000 0000 0000 0000

Each 1 bit represents one of the GPIOs.  So, to control them individually, simply change the value you're writing to the GPIO register to one of each of those.  Now which is which? Try them!

regutil -w GPIO2_PSR=0x00800000
regutil -w GPIO2_PSR=0x00400000
regutil -w GPIO2_PSR=0x00020000

I haven't cracked open my Infocast 8's, only the 3.5" and I had D0 working from the instructions in this thread:
http://forum.chumby.com/viewtopic.php?id=5448

Linux Guy - Occasional Chumby Hacker

Re: Simple GPIO on the Infocast 8

Also, what exactly do you mean for adjusting the output?  You mean voltage?  The datasheet might say otherwise, but I think you're limited to 3.3V for those.  You might be able to use PWM somehow to dim an LED or something, but depending on how it's implemented, it might be a huge CPU drain...?

Linux Guy - Occasional Chumby Hacker

4 (edited by dusk 2012-06-27 19:48:54)

Re: Simple GPIO on the Infocast 8

There's an easier way to use GPIOs - using sysfs.

First, figure out the number of the GPIO you're interested in. Let's say it's GPIO49. First, export it to sysfs:

echo 49 > /sys/class/gpio/export

This will create /sys/class/gpio/gpio49/. Now you can set the direction (to "in" or "out"):

echo out > /sys/class/gpio/gpio49/direction

And the value ("1" or "0"):

echo 1 > /sys/class/gpio/gpio49/value

If you've got the gpio set as an input, you can read from "value" instead.

As far as I'm aware, there's no way to adjust the voltage or drive strength of a gpio, though — they're purely binary.

Re: Simple GPIO on the Infocast 8

I'm not sure how different the infocast 8" kernel is from the infocast 3.5" kernel, but that approach must only work on the infocast 8".

I spent the better part of an evening a couple weeks ago attempting to get the sysfs support working for falconwing (c1/infocast3.5) with no success.

I changed "config ARCH_STMP3XXX" from having "select GENERIC_GPIO" to "select ARCH_WANT_OPTIONAL_GPIOLIB" and enabling gpiolib with sysfs which caused many errors.  First of all, the STMP code includes all of the "gpio_*" functions which gpiolib attempts to provide.  I tried commenting them out so it would link in the STMP ones, didn't work.

I was able to get the /sys/class/gpio directory, but no GPIOs would actually work (and bounds checking was broken, even with ARCH_NR_GPIOS set).

Do you have any insight into getting this working properly for the falconwing platforms?

Linux Guy - Occasional Chumby Hacker

Re: Simple GPIO on the Infocast 8

None at the moment — I'm away from home at the moment, and in any case my Falconwing device isn't currently working.

Word is that the vanilla Linux kernel has pretty decent iMX233 support. I haven't tried it, though!

Re: Simple GPIO on the Infocast 8

dusk wrote:

None at the moment — I'm away from home at the moment, and in any case my Falconwing device isn't currently working.

Word is that the vanilla Linux kernel has pretty decent iMX233 support. I haven't tried it, though!

Maybe I'll try cherry-picking the accelerometer/touchscreen drivers from the Chumby kernel to the vanilla kernel and see where I get...  Problem is, I need to find some free time!

Linux Guy - Occasional Chumby Hacker