* Problem mapping GPIO regs on ppc440gx
@ 2006-05-23 12:48 Travis B. Sawyer
2006-05-23 13:50 ` Travis B. Sawyer
0 siblings, 1 reply; 2+ messages in thread
From: Travis B. Sawyer @ 2006-05-23 12:48 UTC (permalink / raw)
To: linuxppc-embedded
Greetings:
We've been using a 2.4.30 kernel (with numerous patches) on a AMCC 440gx
custom built board for quite some time now.
We're building some new hardware that forces us to go to a 2.6 kernel.
So, I've downloaded 2.6.16.16 from kernel.org and am porting everything
forward from our 2.4.30 kernel.
The problem lies in mapping the GPIO regs of the 440 to user space using
/dev/mem:
gpio_fd = open("/dev/mem", O_RDWR | O_SYNC);
if (0 > gpio_fd) {
perror("mbGpioGet(): Unable to open gpio");
return(-1);
}
addr = (ppc440_gpio_regs_t *)mmap(0, getpagesize() * 2,
PROT_READ | PROT_WRITE,
MAP_SHARED, gpio_fd,
(off_t)(0x40000000));
if (MAP_FAILED == addr) {
perror("mbGpioGet(): map error");
close(gpio_fd);
return(-1);
}
pGpioRegs = (ppc440_gpio_regs_t *)((uint32_t)addr + 0x700);
data = pGpioRegs->in & (MB_GPIO_PRI_N_K | MB_GPIO_SEC_PRES_K);
munmap(0, sizeof(ppc440_gpio_regs_t));
close(gpio_fd);
The data I get back is 0. Always. /SEC_PRES_K should be 1 in this case.
(gdb) print /x addr
$7 = 0x30015000
(gdb) print /x pGpioRegs
$8 = 0x30015700
Checking /proc/<PID>/map shows the mapping:
30015000-30019000 rw-p 30015000 00:00 0
On a board running the 2.4.30 kernel, I show the SAME entry in
/proc/<PID>/map
but I do get data back.
Any idea what I'm doing wrong here?
TIA,
Travis Sawyer
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Problem mapping GPIO regs on ppc440gx
2006-05-23 12:48 Problem mapping GPIO regs on ppc440gx Travis B. Sawyer
@ 2006-05-23 13:50 ` Travis B. Sawyer
0 siblings, 0 replies; 2+ messages in thread
From: Travis B. Sawyer @ 2006-05-23 13:50 UTC (permalink / raw)
To: Travis B. Sawyer; +Cc: linuxppc-embedded
Answering my own question here...
Travis B. Sawyer wrote:
>Greetings:
>
>We've been using a 2.4.30 kernel (with numerous patches) on a AMCC 440gx
>custom built board for quite some time now.
>
>We're building some new hardware that forces us to go to a 2.6 kernel.
>So, I've downloaded 2.6.16.16 from kernel.org and am porting everything
>forward from our 2.4.30 kernel.
>
>The problem lies in mapping the GPIO regs of the 440 to user space using
>/dev/mem:
>
> gpio_fd = open("/dev/mem", O_RDWR | O_SYNC);
>
> if (0 > gpio_fd) {
> perror("mbGpioGet(): Unable to open gpio");
> return(-1);
> }
>
> addr = (ppc440_gpio_regs_t *)mmap(0, getpagesize() * 2,
> PROT_READ | PROT_WRITE,
> MAP_SHARED, gpio_fd,
> (off_t)(0x40000000));
>
>
>
The above mmap call worked for 2.4.30, but for 2.6.16 I needed to change
the offset
to be a multiple of page size, so:
(off_t)(0x40000000/getpagesize());
-travis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-05-23 13:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-23 12:48 Problem mapping GPIO regs on ppc440gx Travis B. Sawyer
2006-05-23 13:50 ` Travis B. Sawyer
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).