Difference between revisions of "GPIO Driver"
Revision as of 12:21, 19 September 2006
On this page, you will find all the informations needed to use the Armadeus GPIO driver.
Module compilation & installation
The first thing you have to do is to compile the driver. The only way to do that actually is to compile it as a module:
# cd driver_directory
Be sure to have ARMADEUS_KERNEL_DIR environment variable defined. If not:
# export ARMADEUS_KERNEL_DIR=/local/julien/Armadeus/Armadeus_SVN_test/armadeus/software/buildroot/build_arm_nofpu/linux-2.6.12/ (for example)
# make ARCH=arm CROSS_COMPILE=/local/julien/Armadeus/Armadeus_SVN_test/armadeus/software/buildroot/build_arm_nofpu/staging_dir/bin/arm-linux-
When compiled, you will obtain 3 modules:
- gpio.ko: this is the main driver. It should be loaded first and will allow you to easily control gpio pin from user space.
- ppdev.ko: this is an extension driver to add PPDEV emulation. This way you will be able to emulate a standard parallel port on one GPIO port (and then for example connect a LCD)
- loadfpga.ko: this is an extension driver to add the possibility to load the fpga on APF boards from linux userspace -> fpga reprogrammation after linux boot.
Then, you have to:
- copy these modules on your rootfs in /lib/modules/to_be_defined/
- copy loadgpio.sh script on your rootfs in /etc/
After that you can launch:
# sh /etc/loadgpio.sh
or look inside this script if you want to manually enter the module parameters
# insmod /lib/modules/2.6.10-imx/drivers/gpio.ko portB_init=0,0,0x00FFFF00,0,0,0,0,0,0x0FF00000,0,0,0,0,0,0,0x0FF00000
gpio .ko module parameters are values for PORTA, PORTB, PORTC, PORTD configuration registers in following order: DDIR, OCR1, OCR2, ICONFA1, ICONFA2, ICONFB1, ICONFB2, DR, GIUS, SSR, ICR1, ICR2, IMR, GPR, SWR, PUEN,
GPIO driver is usable through 2 interfaces:
- use /proc/drivers/gpio/portXdir to read (cat) or write (echo) pin direction
- use /proc/drivers/gpio/portX to read (cat) or write (echo) pin status
Examples: See which IO-Pins of PortD are configured as inputs, and which are outputs ('1' = output, '0' = input):
# cat /proc/driver/gpio/portDdir##
Configure the IO-Pins 30, 28, 23, 22 and 21 of PortB as outputs, all others are inputs:
# echo 01010000111000000000000000000000 >/proc/driver/gpio/portBdir
Read the status of the IOs of PortB:
# cat /proc/driver/gpio/portB
Set bits 30, 28 and 23 of PortB to '1', all other outputs to '0':
# echo 01010000100000000000000000000000 > /proc/driver/gpio/portB