From: "Guillaume Dargaud" <dargaud@lpsc.in2p3.fr>
To: <linuxppc-dev@ozlabs.org>
Subject: Xilinx GPIO API and kernel GPIO API differences
Date: Wed, 3 Sep 2008 15:50:51 +0200 [thread overview]
Message-ID: <155401c90dcc$18026770$ad289e86@LPSC0173W> (raw)
Hello all,
I can't fully understand the differences in what should be simple I/O
read/writes.
If I write a standalone program using the Xilinx API calls, I have access to
the following functions to control the direction of GPIO bits. For instance:
XGpio Input, Output;
XGpio_Initialize(&Input, InputDev);
XGpio_Initialize(&Output, OutputDev));
XGpio_SetDataDirection(&Input, 1, 0xFFFFFFFF);
XGpio_SetDataDirection(&Output, 1, 0);
Data = XGpio_DiscreteRead(&Input, 1);
XGpio_DiscreteWrite(&Output, 1, 0x12345678);
Now the equivalent using usermode linux calls _seems_ to be the following:
struct xgpio_ioctl_data Input, Output;
Input = open(GPIO_IN, O_RDWR);
Output = open(GPIO_OUT, O_RDWR);
gpio_info.chan = 1;
gpio_info.mask = 0xFFFFFFFF;
ioctl(Input, XGPIO_IN, &gpio_info);
Data=gpio_info.data;
gpio_info.data=0x12345678;
ioctl(Output, XGPIO_OUT, &gpio_info);
But where it all breaks down is if I have input and output bits mixed on the
same GPIO, particularly if reading the outputs makes no sense like in my
case (always return 0).
Using those ioctl calls, how do I specify which bits are input and which
ones are output ?
In other words, the equivalent to this:
XGpio IO;
XGpio_Initialize(&IO, Dev);
XGpio_SetDataDirection(&Input, 1, 0x00FFFF00);
Data = XGpio_DiscreteRead(&Input, 1);
XGpio_DiscreteWrite(&Output, 1, 0x12000078);
Is there anything available from usermode besides those ioctl calls ?
This makes me regret assembly...
--
Guillaume Dargaud
http://www.gdargaud.net/
reply other threads:[~2008-09-03 13:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='155401c90dcc$18026770$ad289e86@LPSC0173W' \
--to=dargaud@lpsc.in2p3.fr \
--cc=linuxppc-dev@ozlabs.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).