GPIO driver module for Jetway NF98 board

Joan Pau Beltran joanpau.beltran at uib.cat
Wed Dec 21 12:34:58 EST 2011


Hi everyone,

I did not find any existing driver for the GPIO port of the Jetway NF98 
mini-itx board, so I would like to write a module for that, using the 
gpiolib interface.

Since the board documentation does not include any information about the 
GPIOs, I contacted the Jetway support team. However, the only answer was 
the attached code for Windows (NF98GPIO.c).
As you can see, it seems clear how to set the pin states for output, but 
not how to read them in input mode. I asked again and the response was 
(literally):
> input sample code:
> {
> data= ISA_RW(GPIO_BASE[pin]+0x2,highlow<<pin,1,~(1<<pin));
> }
> //final exit SIO
> outp(INDEX_PORT,0xaa);
> return data;
It makes no sense, and it is very upsetting.
I would try to read from the same address used for output, but this is 
just an idea to be tested.

Since I have not written any kernel module before, after reading the 
pertinent documentation about memory management, i/o port access, and 
gpiolib, I have some questions.

1. How should I request/release the ports mentioned in the attached 
file? Should I use the request_region/release_region functions from 
linux/ioport.h? In such case, what should I do with the returned struct 
resource?

2. I suppose that I should use the same addresses given by the support 
team, although their code is for windows. Is it ok?

3. Should/could I use the test_bit, set_bit, clear_bit functions to get, 
set the bit in the needed read/write functions I am writing? Or should I 
use the sequence 'inb - mask the value properly - outb' ?


The second file attached is an skeleton of the module I am trying to 
write, any comments or suggestions are welcome.

Thanks in advance!

-- 
Joan Pau Beltran

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111221/5e38755c/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gpio-jwnf98.c
Type: text/x-csrc
Size: 2748 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111221/5e38755c/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NF98GPIO.c
Type: text/x-csrc
Size: 2179 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20111221/5e38755c/attachment-0001.bin 


More information about the Kernelnewbies mailing list