All of lore.kernel.org
 help / color / mirror / Atom feed
* GPIO driver module for Jetway NF98 board
@ 2011-12-21 17:34 Joan Pau Beltran
  2011-12-22  1:21 ` Josh Cartwright
       [not found] ` <20111222001549.GA14353@joshcartwright.net>
  0 siblings, 2 replies; 7+ messages in thread
From: Joan Pau Beltran @ 2011-12-21 17:34 UTC (permalink / raw)
  To: kernelnewbies

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 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-01-23 21:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-21 17:34 GPIO driver module for Jetway NF98 board Joan Pau Beltran
2011-12-22  1:21 ` Josh Cartwright
     [not found] ` <20111222001549.GA14353@joshcartwright.net>
2011-12-28 17:03   ` Joan Pau Beltran
2011-12-29 17:53     ` Josh Cartwright
2012-01-18 20:48       ` Joan Pau Beltran
2012-01-18 21:40         ` Joan Pau Beltran
2012-01-23 21:00           ` Joan Pau Beltran

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.