01/Feb/2007 This ist the new and overworked version of a the driver for all GPIO an LED. Now we have 8 GPIO (BGA-case) or 4 GPIO with the PLCC-case. Also now all 15 ports from the Ethernet-switch are possible as input, output or as all modes described in the datasheed. The driver IS limited compatible with the old driver. The needed ioctl-call for led on/off are vailable. Now also ioctl-calls to get and set the mode and value for the leds/gpios are ready for use. The biggest differenz to the old driver is the device-id and the led-numbering. This driver use only the major device-id 167 with minor number 0 to 22. For example "mknod /dev/gpio0 c 167 0". For old programs you have to symlink the name /dev/led0 to this /dev/gpio0. Please modify your start-scripts. To make the dev entries you can use this code : ----------------------------------------------- i=0 while [ $i != 23 ] do mknod /dev/gpio$i c 167 $((i++)) done ----------------------------------------------- The numbering for Edimax BR6104k is: gpio0 = power-led gpio1 = unused ( used with i2c yet ) gpio2 = Reset-switch gpio3 = unused ( used with i2c yet !! used with 4MB-flash mod also !! ) gpio4 .. gpio7 not available because of PLCC-chip GPIO 8: LINK_ACT \ GPIO 9: SPEED > switch port 0 (wan) GPIO 10: DUPLEX_COL / GPIO 11: LINK_ACT \ GPIO 12: SPEED > switch port 1 (lan) GPIO 13: DUPLEX_COL / GPIO 14: LINK_ACT \ GPIO 15: SPEED > switch port 2 (lan) GPIO 16: DUPLEX_COL / GPIO 17: LINK_ACT \ GPIO 18: SPEED > switch port 3 (lan) GPIO 19: DUPLEX_COL / GPIO 20: LINK_ACT \ GPIO 21: SPEED > switch port 4 (lan) GPIO 22: DUPLEX_COL / On Edimax "BR6104K(P)" the DUPLEX_COL led are not connected ! This version do not initialize the gpio or led ! The setting above are from the hardware reset. This is to prevent conficts with other driver they use the gpios. You can change any mode in init scripts or in programs. You do not need any tool for config. The current status can you see with "cat /proc/driver/led". To set a gpio you can send a string to the device /dev/gpioX or you can use the ioctl-call via /dev/gpio0 (see led_set.c and gpiodemo.c for example). String commands are : "led on" : power on the led "led off" : power off the led "led invert" : change the assignment on/off to low/high-level "led switch x" : set the mode to x (x = 0..1 for gpio0..7 , 0..13 for gpio8..22) "led blink n" : blink the led with n ms For understanding the funktion: - the gpio0 .. gpio7 can only set to input or output example: echo "led switch 0" > /dev/gpio1 set gpio1 to input echo "led switch 1" > /dev/gpio2 set gpio2 to output - only if in output mode you can set the led on or off echo "led on" > /dev/gpio2 set the led on - in both modes you can change the assignment between "on" and "off" to the physical high or low level with the "invert" statement. echo "led invert" > /dev/gpio2 normal : on = high-level (3.3V) on the pin, LED is wired between GPIO and GND used on Edimax Power-LED invert : on = low-level (0V) on the pin , LED is wired between GPIO an +3.3V used on Edimax Switch-LEDs - the gpio8 .. gpio22 can set to 11 modes (with 14 mode-numbers). for compatibily the modes 0 and 1 are identical to gpio0 .. gpio7. - the other modes are from the datasheed the mode "1" (flash) from the datasheet is moved to mode number 13. echo "led switch 0" > /dev/gpio8 set gpio8 to input echo "led switch 1" > /dev/gpio10 set gpio10 to output echo "led switch 9" > /dev/gpio9 set gpio8 to LINK_ACT echo "led switch 13" > /dev/gpio17 set gpio8 to FLASH, the hardware-blink-mode - all gpio's can set to the software blink if in output mode with echo "led blink 1000" > /dev/gpio12 blinks gpio12 with 1s pulse If you read from the device for example with "cat /dev/gpio8" you can see the current mode (the real settings of the register) if not in input mode. If you have set the gpio with "led on","led off" or "led blink xxx" you see this entry. If in input mode you see the value 0 or 1 from the input, conditioned from the "invert" state. known bugs: - on the led lines are a small low level puls if you switch from input to output_1. The leds have 2 seperate modes for output, called output_0 and output_1 in datasheet. output_1 set the line to high level, output_0 to low level. If the line is switched from input to this high level output a low level pulse with 35..45ns is occur. I think its a hardware bug or the C compiler generate bad code. The lcd_out_4x20.c is a example how to drive a standart lcd over this driver. For questions or suggestion please mail to dl4huf@darc.de.