kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: joanpau.beltran@uib.cat (Joan Pau Beltran)
To: kernelnewbies@lists.kernelnewbies.org
Subject: GPIO driver module for Jetway NF98 board
Date: Wed, 21 Dec 2011 18:34:58 +0100	[thread overview]
Message-ID: <4EF218C2.3090807@uib.cat> (raw)

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 

             reply	other threads:[~2011-12-21 17:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21 17:34 Joan Pau Beltran [this message]
2011-12-22  1:21 ` GPIO driver module for Jetway NF98 board 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EF218C2.3090807@uib.cat \
    --to=joanpau.beltran@uib.cat \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).