Home 
Soekris GPIO kernel module

I searched the net for the kernelmodule to access the GPIO.

Turns out I had to write (adapt, that is) it myself. I'll tell you how I came to it.

ON7LDS.


 

1. The easy way: /dev devices

Ok, I got my soekris with ubuntu on it. In fact, I started with debian (my favorite) but I'll tell you later why I switched to ubuntu.

After some searching, I found http://lists.soekris.com/pipermail/soekris-tech/2006-November/011203.html. Based on the information and the script found there, I made a new script with more functionality.
This script uses the modules cs5535_gpio and pc8736x_gpio to create /dev/ devices to control the soekris error led and the general purpose IO.

You can find it here and an error led test script here.



2. The less easy way: the kernel module

I also came across the site of Martin Hejl http://soekris.hejl.de/ where I could find drivers for the net4801 for the 2.2 kernel.

There is a link to the site of Stanislav Meduna http://www.meduna.org/sw_gpio_en.html where the port to kernel 2.6 could be found.

Trying to compile the code for kernel 2.6, I ran into some serious problems. I was not able to compile for the 2.6.26 kernel my system is running. Writing kernel modules is not that simple, and after some extensive searching, failing to solve the problem, I finally contacted Stanislav Meduna. Unfortunately he no longer has a Soekris in operation nor a kernel build tree for that platform. He gave me some tips, but I was not able to solve the problems and compile the lot.

I then called the emergency line : I contacted Geert Uytterhoeven. After some modifications, he could compile the module on a ubuntu 10.04 system with 2.6.32 kernel. With these modifications, strange enough, I was not able to compile it on my system (debian with kernel 2.6.26). I decided to switch the soekris to ubuntu and with the help of Geert I finally was able to compile the kernel module.

There came the next disappointment : the module did not recognize the net5501 and made the assumption it was a 4501. But the 5501 has 12 GPIOs and the 4501 only 8. Not good ...

With the patch from http://old.nabble.com/GPIO-for-net5501-under-Linux-2.6--td16408801.html it was better, but not yet good enough. The kernel module now takes the 5501 for a 4801 and the GPIO did function. But not the error led.

So I studied the code from the cs5535_gpio module (part of the kernel tree), and with that and all info I got till now, I changed the gpio-1.3.2+trillian0.01 source code and created the gpio-1.3.3 sources. These compile into a gpio.ko kernel module.
When this kernel module is loaded, it should be able to see if it runs on a 4501, 4801 or 5501 and create the correct /proc/driver/soekris* files. I could only test it on a 5501 (the one I got) - there it works nicely.

root@soekris:/usr/src# modprobe gpio
root@soekris:/usr/src# tail /var/log/syslog -n 3
Nov 30 20:52:36 soekris kernel: [ 4780.520907] gpio: found bridge device 1022:2080
Nov 30 20:52:36 soekris kernel: [ 4780.548095] gpio: base at 6100
Nov 30 20:52:36 soekris kernel: [ 4780.566408] gpio: Soekris net5501 GPIO driver Version 1.3.3 (C) 2010 Lieven De Samblanx
root@soekris:/usr/src# ls -al /proc/driver/soekris*
-rw-r--r-- 1 root root 0 2010-11-30 20:54 /proc/driver/soekris_error_led
-rw-r--r-- 1 root root 0 2010-11-30 20:54 /proc/driver/soekris_gpio
-rw-r--r-- 1 root root 0 2010-11-30 20:54 /proc/driver/soekris_io_settings
-r--r--r-- 1 root root 0 2010-11-30 20:54 /proc/driver/soekris_temp
-r--r--r-- 1 root root 0 2010-11-30 20:54 /proc/driver/soekris_voltage
root@soekris:/usr/src#


I tested the gpio kernel module (on the photo you see the 20 pin header with ribbon cable soldered to a blue test pcb on the left of the soekris) and every IO did work.

I then made a pcb to connect to JP10 to drive a TNC, but that's another story (check the TNC project pages)

The sources do not yet fully compile the lcd driver, I'm testing the lcd driver at this moment.