GPIO on ALIX.3D3
The AMD CS5536 Geode companion on the ALIX.3D3 board has several general purpose input/output pins. Most of them have different functions as well, and there are some registers to set if they should be used as special function GPIO pins. The ALIX.3D3 uses 4 GPIO pins for 3 LEDs and 1 mode switch. Accessing the leds is very easy using the leds-alix2 driver, but they can be addressed as GPIO as well. There is already a driver for the GPIO pins in the kernel named cs5535_gpio.c, but it uses a non standard interface to communicate with kernel. So, I wrote a new kernel driver using the GPIO interface.
Installating is very easy: Download the patch (GPIO drivers for AMD CS5535/CS5536 (Kernel 2.6.30-rc6)), patch it and compile the kernel:
wget http://www.twam.info/wp-content/uploads/2009/05/gpio.patch -O /root/gpio.patch cd /usr/src/linux patch -p1 < /root/gpio.patch
Now run kernel configuration and select
Device Drivers ---> [*] GPIO Support ---> [*] /sys/class/gpio/... (sysfs interface) <*> AMD CS5535/CS5536 (Geode Companion Device)
Compile the kernel and reboot. If you go to /sys/class/gpio there should be a file name gpiochip0. Now we can enable some pins and test them. By
echo 6 > /sys/class/gpio/export
we tell the kernel, that we want to use pin 6 from userspace. Pin 6 is connected to led. Now we configure pin 6 as an output by
echo out > /sys/class/gpio/GPIO6/direction
Now we can toggle the values by
echo 1 > /sys/class/gpio/GPIO6/value sleep 1 echo 0 > /sys/class/gpio/GPIO6/value
Notice, that the LED is connected to 3.3V, so setting value to 0 it will be lit. The other LEDs are connected to pin 25 & pin 27. On pin 24 is a switch connected. We can read the value by enabling the pin, setting it as an input and reading the value:
echo 24 > /sys/class/gpio/export echo in > /sys/class/gpio/GPIO24/direction cat /sys/class/gpio/GPIO24/value
As the pin has an internal pull up, it will show 1 if the switch isn’t pressed or installed. If you press the switch or connect to the metal pins, it will result in 0.
Don’t forget to unexport all pins after when you’re done:
echo 6 > /sys/class/gpio/unexport echo 24 > /sys/class/gpio/unexport
Any feedback on the driver is welcome!

The cs5535-gpio support via the GPIO interface is in kernel mainline since version 2.6.33-rc1. Commits are 5f0a96b044d8edaee20f4a32ef6c393599ca55f8 and 1ea3fa7bbfbe81cfbdcc35748a57c35f9b32c5d6.
Dear twam:
Thank you for your wonderfull articles about alix.3d3 board. I am working in a project in Voyage Linux for this board, and I am very pleased of how everything works with release 0.6.5. Very small bugs with a very good functionallity. I have readed your articles about LEDS, GPIO, etc… and they helped much. The problem I have, as I readed in one of your articles is that I want to use the gpio24 for a switch and I have asked about it and If I don’t want to compile the kernell (I hate that) I can now use and load with modprobe the cs5535 as this:
voyage:~# modprobe cs5535_gpio
voyage:~# dmesg | grep gpio
[ 14.847516] cs5535_gpio: base=0×6100 mask=0xb003c66 major=253
voyage:~# lsmod | grep gpio
cs5535_gpio 3744 0
voyage:~# ls -l /dev/cs5535*
crw-rw—- 1 root root 253, 1 Jun 6 21:37 /dev/cs5535_gpio1
crw-rw—- 1 root root 253, 10 Jun 6 21:37 /dev/cs5535_gpio10
crw-rw—- 1 root root 253, 11 Jun 6 21:37 /dev/cs5535_gpio11
crw-rw—- 1 root root 253, 12 Jun 6 21:37 /dev/cs5535_gpio12
crw-rw—- 1 root root 253, 13 Jun 6 21:37 /dev/cs5535_gpio13
crw-rw—- 1 root root 253, 2 Jun 6 21:37 /dev/cs5535_gpio2
crw-rw—- 1 root root 253, 24 Jun 6 21:37 /dev/cs5535_gpio24
crw-rw—- 1 root root 253, 25 Jun 6 21:37 /dev/cs5535_gpio25
crw-rw—- 1 root root 253, 27 Jun 6 21:37 /dev/cs5535_gpio27
crw-rw—- 1 root root 253, 5 Jun 6 21:37 /dev/cs5535_gpio5
crw-rw—- 1 root root 253, 6 Jun 6 21:37 /dev/cs5535_gpio6
And it’s very easy and is ok. But just a stupid question. How can I read when I want or as is changed the value of the switch: 0/1? Can you help me?
Thank you
Yago
@Yago Fernandez Hansen
I never used the old device module as I is not compatible with the GPIO interface of the kernel. Also this will be removed in future kernel version, so it is better not to use it in new projects.