linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Endian problem when accessing internel regs on 8347
@ 2008-01-17  6:26 Bruce_Leonard
  2008-01-17 15:01 ` Ben Warren
  2008-01-17 17:39 ` Scott Wood
  0 siblings, 2 replies; 11+ messages in thread
From: Bruce_Leonard @ 2008-01-17  6:26 UTC (permalink / raw)
  To: linuxppc-embedded

Hi,

I've got an MPC8347 running the 2.6.24-rc5 kernel and I'm trying to access 
the GPIO registers.  I already have a driver that's doing related work 
(tho across PCI) and I just want to remap the internal CPU address to a 
kernal address and be able to read/write the register using an IOCTL call 
from user space.  My problem is, every accessor I try does an endian 
conversion before giving me my data.  So here's some code snipits of what 
I'm doing:

request_mem_region(0xe0000c00, 24, "my driver");  // 0xe0000c00 is the 
memory mapped location of the GPIO regs
data_ptr2 = ioremap(0xe0000c00, 24);

Then in the IOCTL function I try to read from the register.  First I 
tried:

ioread32(data_ptr2);

I know that the mapping is working okay because I got the data from the 
GPIO direction register, but it's been byte swapped.  The contents of the 
register are 0xFFFFFFE7, but what my user space app gets back is 
0xE7FFFFFF.  I've tried all the varients I can find, readl(), inl(), 
in_be32(), in_le32(), even __raw_readl().  They all give me back byte 
swapped data.  I'm very confused.  Especially since I've looked at 
in_be32() and in_le32(), they're both inline assembly, and they use 
different instructions.  They can't be giving me the same results.  I'm 
sure I'm not the first person to want to access PowerPC internal registers 
through a driver.  Can anyone give me a hint what I'm doing wrong?

As an additional question related to PowerPC inline assembly, can anyone 
tell me what "%U1%X1" means in the following:

__asm__ __volatile__("lwz%U1%X1 %0,%1; twi 0,%0,0; isync" : "=r" (ret) : 
"m" (*addr));

Thanks.

See 'ya!

Bruce

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

end of thread, other threads:[~2008-01-22  5:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-17  6:26 Endian problem when accessing internel regs on 8347 Bruce_Leonard
2008-01-17 15:01 ` Ben Warren
2008-01-17 18:01   ` Bruce_Leonard
2008-01-17 18:25     ` Ben Warren
2008-01-17 17:39 ` Scott Wood
2008-01-17 18:38   ` Bruce_Leonard
2008-01-17 22:18     ` Scott Wood
2008-01-21  7:21       ` Bruce_Leonard
2008-01-21 15:16         ` Ben Warren
2008-01-21 16:40         ` Scott Wood
2008-01-22  5:33           ` Bruce_Leonard

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).