[Soekris] GPIO support for the net-4801 on Linux

Jan Neskudla janban at centrum.cz
Fri Nov 10 18:04:52 UTC 2006


______________________________________________________________
> Od: arnau at ehas.org
> Komu: soekris-tech at lists.soekris.com
> Datum: 05.11.2006 00:01
> Předmět: [Soekris] GPIO support for the net-4801 on Linux
>
>Hello,
>
>I have a Soekris net4801 with voyage v0.2 installed (it includes a kernel

>2.6.15-486-voyage). I needed to use the GPIO for digital input/output,
and 
>looking for information I found this message from Jim Cromie:
>
>http://lists.soekris.com/pipermail/soekris-tech/2006-June/010550.html
>
>So I compilled a 2.6.17 kernel (from debian 'testing') with those patches

>applied and installed it. Then, my first problem was that I didn't know
how to 
>create the /dev/gpio-* files to interface the GPIO. Playing with the
board I 
>finally found the correspondance between the minor device values and the
12 GPIO 
>pins (16 17 18 19 20 21 22 23 4 5 11 10)
>
>Then I added this to /etc/modules:
>
>pc87360 -> that's because I use sensors
>pc8736x_gpio
>
>and created /etc/modprobe.d/gpio:
>
>options pc87360 init=3
># not really sure of that... :-(
>install pc8736x_gpio /sbin/modprobe --ignore-install pc8736x_gpio && 
>/usr/local/sbin/gpio-dev create
>
>with gpio-dev being:
>
>#!/bin/sh
># Create/remove device files for net4801 GPIO
>
>MAJOR=254
>BASE="/dev/gpio"
># Minor values from GPIO0 to GPIO11 (tested on net4801)
>MINOR_LIST="16 17 18 19 20 21 22 23 4 5 11 10"
>
>OP=$1
>if [ "$OP" != "create" -a "$OP" != "remove" ]; then
>	echo "usage: gpio-dev create|remove"
>	exit 1
>fi
>
>NUM=0
>for MINOR in $MINOR_LIST; do
>	FILE=$BASE-$NUM
>	if [ -e $FILE ]; then rm -f $FILE; fi
>	if [ "$OP" = create ]; then
>		mknod $FILE c $MAJOR $MINOR
>	fi
>	let NUM=NUM+1
>done
>
>Surprisingly, it worked smoothly.
>
>Inspecting the kernel source I found how to configure the pins:
>
>echo VALUE > /dev/gpio-X
>
>where VALUE can be: O (output), o (input), T (push-pull), t (open drain),
P 
>(pull-up enabled), p (pull-up disabled), v (print settings), c (get
driven and 
>read value). And of course, 1 to output high, and 0 to output low.
>
>Example: input from GPIO-0 with pull-up enabled:
>
>echo "oP" > /dev/gpio-0
>cat /dev/gpio-0
>
>Example: output 1 to GPIO-0 with open-drain:
>
>echo "Ot1" > /dev/gpio-0
>
>...
>
>By the way, I have a problem with the pc8736x_gpio module: if I rmmod it
and 
>then do a modprobe, it fails:
>
>meta:~# modprobe pc8736x_gpio
>meta:~# rmmod pc8736x_gpio
>meta:~# modprobe pc8736x_gpio
>FATAL: Error inserting pc8736x_gpio 
>(/lib/modules/2.6.17-voyage-ehas/kernel/drivers/char/pc8736x_gpio.ko): No
such 
>device
>FATAL: Error running install command for pc8736x_gpio
>
>...
>
>Well, now the question is: although all of this works, I am not sure if
this is 
>the correct procedure, is there any better way to do it?
>
>Anyway, I expect this info helps other people... :-)
>
>By the way, has anybody tested the TTL COM2 included in the 20-pin GPIO
connector?

Hi Arnau, 

 i was playing a bit with that COM port. It it`s not  a COM2 TTL , it is only TTL of COM1 it means that you can use DB-9 connector  to use COM1 with RS232 bus driver or plug your device directly to TTL input of COM1. So there are only two serial ports COM0 COM1. I case of using TTL levels the driver chip MAX??? is disabled (i thing). 
                                                   Best Jan 



>regads
>arnau
>
>pd: many thanks, of course, to Jim for this great work on the GPIO
interface! I 
>hope the official kernel include his patches soon.
>_______________________________________________
>Soekris-tech mailing list
>Soekris-tech at lists.soekris.com
>http://lists.soekris.com/mailman/listinfo/soekris-tech
>



More information about the Soekris-tech mailing list