From: "A. Nolson" <alohanono@gmail•com>
To: linuxppc-embedded@ozlabs•org
Subject: Problems when accessing to registers in GPIO
Date: Sat, 01 Mar 2008 23:10:56 +0100 [thread overview]
Message-ID: <47C9D470.5000604@gmail.com> (raw)
Hi,
I am getting some problems when trying to access to the GPIO registers
from the userland of my secretlab's linux 2.6.24-rc3 ( Xilinx ML403 ). I
am using io_remap() functions ( from
http://www.denx.de/wiki/bin/view/PPCEmbedded/DeviceDrivers ) and I was
successfully able to test them with some own-made IP cores. However, I
am having problems when trying to do it in the same way with the GPIO IP
core from Xilinx ( the ones I am using to interface to the LEDs ,
buttons and LCD ).
If I try to access to the buttons in the board I don't really have any
problem since the tri-state control register is automatically set to
"all inputs" when the IP is turned on. But when I try to use the LEDs
and I need to configure the tris-state as outputs, they don't work . I
am doing the following:
//memory mapping
if( (led_base = (volatile int*) ioremap(BASE_GPIO,8)) == NULL ||
(but_base = (volatile int*) ioremap(BASE_GPIO_B, 8)) == NULL )
{
perror( "Cannot allocate memory for GPIO/n");
return 1;
}
led_tri = (char*)led_base + 0x4;
but_tri = (char*)but_base + 0x4;
//configure as inputs and outputs
printf("configuring IOs...");
*led_tri = 0x00;//configure them as outputs
*but_tri = 0xFF;//configure them as inputs
while(1)
{
data = *but_base;
// printf("data:%x\n",data);
*led_base = data;
usleep(50000);
}
If I try to allocate the tri-state registers as integer I get "Bus
Error" when accessing to them. I don't know really what is the problem.
If I try to the same without operating system, this is, directly using
XPS, I manage to make the buttons and leds work perfectly. Anybody can
help me with this?
/A
reply other threads:[~2008-03-01 22:11 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=47C9D470.5000604@gmail.com \
--to=alohanono@gmail$(echo .)com \
--cc=linuxppc-embedded@ozlabs$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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