* a question on "iowrite32()"
@ 2007-06-06 19:30 Ming Liu
2007-06-07 6:20 ` Domen Puncer
0 siblings, 1 reply; 6+ messages in thread
From: Ming Liu @ 2007-06-06 19:30 UTC (permalink / raw)
To: linuxppc-embedded
Dear all,
I am writing a device driver for my customized PLB hardware module on my
PPC405 & Xilinx ML403 architecture. In the driver code, I use a
"iowrite32()" function to initiate a DMA transfer. However, I found that if
I program as "iowrite32(0x12345678, address);", actually I am writing
0x87654321 to that address. However if I write a standalone program without
a Linux OS, the Xilinx function "XIo_Out32()" just write the correct value
0x12345678 into address. Can anyone explain my why this happens? I know
that PPC405 is a big-endian system. But I don't think this is a endian
problem. After all endian is only an issue of the CPU architecture, not the
OS. Am I right?
Thanks for your hints.
BR
Ming
_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: a question on "iowrite32()"
2007-06-06 19:30 a question on "iowrite32()" Ming Liu
@ 2007-06-07 6:20 ` Domen Puncer
2007-06-07 10:01 ` Arnd Bergmann
0 siblings, 1 reply; 6+ messages in thread
From: Domen Puncer @ 2007-06-07 6:20 UTC (permalink / raw)
To: Ming Liu; +Cc: linuxppc-embedded
On 06/06/07 19:30 +0000, Ming Liu wrote:
> Dear all,
> I am writing a device driver for my customized PLB hardware module on my
> PPC405 & Xilinx ML403 architecture. In the driver code, I use a
> "iowrite32()" function to initiate a DMA transfer. However, I found that if
> I program as "iowrite32(0x12345678, address);", actually I am writing
> 0x87654321 to that address. However if I write a standalone program without
> a Linux OS, the Xilinx function "XIo_Out32()" just write the correct value
> 0x12345678 into address. Can anyone explain my why this happens? I know
> that PPC405 is a big-endian system. But I don't think this is a endian
> problem. After all endian is only an issue of the CPU architecture, not the
> OS. Am I right?
out_be32?
I recall something about iowrite32 being PCI stuff and therefore little
endian, but don't count on this being right.
Domen
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: a question on "iowrite32()"
2007-06-07 6:20 ` Domen Puncer
@ 2007-06-07 10:01 ` Arnd Bergmann
2007-06-07 11:20 ` Ming Liu
0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2007-06-07 10:01 UTC (permalink / raw)
To: linuxppc-embedded; +Cc: linuxppc, Domen Puncer
On Thursday 07 June 2007, Domen Puncer wrote:
> out_be32?
> I recall something about iowrite32 being PCI stuff and therefore little
> endian, but don't count on this being right.
You're completely right, out_be32 is the correct one. The primitives
we have for writing 32 bit I/O space are:
writel(): PCI memory space from ioremap
outl(): PCI I/O space from a struct resource
iowrite32(): PCI memory or I/O space from pci_iomap
iowrite32be(): defined but not useful anywhere currently
out_be32(): big-endian memory address from of_address_to_resource or of_iomap
out_le32(): like out_be32(), but little-endian
__raw_writel(): always broken, don't use
Since of_iomap() is rather new and hardly used by any drivers, we
could still redefine it so that you would use iowrite32{,be}() instead
of out_{be,le}32, but currently that doesn't work.
I also thought about changing of_iomap() to use the devres functions,
which basically attach information about the mapping to the device
structure, and automatically unmap those when the of_platform_driver
gets unregistered.
Arnd <><
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: a question on "iowrite32()"
2007-06-07 10:01 ` Arnd Bergmann
@ 2007-06-07 11:20 ` Ming Liu
2007-06-07 14:09 ` Arnd Bergmann
0 siblings, 1 reply; 6+ messages in thread
From: Ming Liu @ 2007-06-07 11:20 UTC (permalink / raw)
To: arnd; +Cc: domen.puncer, linuxppc-embedded
Dear Arnd,
>Since of_iomap() is rather new and hardly used by any drivers, we
>could still redefine it so that you would use iowrite32{,be}() instead
>of out_{be,le}32, but currently that doesn't work.
So if I am correct, your suggestion is to use iowrite32be() in my device
driver, right? However, I cannot find such a function defined in my 2.6.10
kernel. Isn't iowrite32be() a standard IO function like iowrite32(), or
there is a patch to export this function?
Thanks for your information.
BR
Ming
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: a question on "iowrite32()"
2007-06-07 11:20 ` Ming Liu
@ 2007-06-07 14:09 ` Arnd Bergmann
2007-06-08 13:51 ` Ming Liu
0 siblings, 1 reply; 6+ messages in thread
From: Arnd Bergmann @ 2007-06-07 14:09 UTC (permalink / raw)
To: Ming Liu; +Cc: domen.puncer, linuxppc-embedded
On Thursday 07 June 2007, Ming Liu wrote:
> >Since of_iomap() is rather new and hardly used by any drivers, we
> >could still redefine it so that you would use iowrite32{,be}() instead
> >of out_{be,le}32, but currently that doesn't work.
>
> So if I am correct, your suggestion is to use iowrite32be() in my device
> driver, right?
What I was saying is that iowrite32be is broken for other reasons, as it
is only defined for PCI and ISA devices and you should _not_ use it,
even if it solves the endianess problem.
What you should use is out_be32().
> However, I cannot find such a function defined in my 2.6.10 kernel.
> Isn't iowrite32be() a standard IO function like iowrite32(), or there is
> a patch to export this function?
It's a standard function, is was added less than two years ago.
You should really consider upgrading to a recent kernel version for
a number of reasons, but they are all unrelated to your current problem ;-)
Arnd <><
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: a question on "iowrite32()"
2007-06-07 14:09 ` Arnd Bergmann
@ 2007-06-08 13:51 ` Ming Liu
0 siblings, 0 replies; 6+ messages in thread
From: Ming Liu @ 2007-06-08 13:51 UTC (permalink / raw)
To: arnd; +Cc: domen.puncer, linuxppc-embedded
Dear Arnd,
I have turned to use out_be32. My system works quite well now. Thanks for
your suggestions. :)
BR
Ming
>From: Arnd Bergmann <arnd@arndb•de>
>To: "Ming Liu" <eemingliu@hotmail•com>
>CC: domen.puncer@telargo•com, linuxppc-embedded@ozlabs•org
>Subject: Re: a question on "iowrite32()"
>Date: Thu, 7 Jun 2007 16:09:18 +0200
>
>On Thursday 07 June 2007, Ming Liu wrote:
> > >Since of_iomap() is rather new and hardly used by any drivers, we
> > >could still redefine it so that you would use iowrite32{,be}() instead
> > >of out_{be,le}32, but currently that doesn't work.
> >
> > So if I am correct, your suggestion is to use iowrite32be() in my
device
> > driver, right?
>
>What I was saying is that iowrite32be is broken for other reasons, as it
>is only defined for PCI and ISA devices and you should _not_ use it,
>even if it solves the endianess problem.
>
>What you should use is out_be32().
>
> > However, I cannot find such a function defined in my 2.6.10 kernel.
> > Isn't iowrite32be() a standard IO function like iowrite32(), or there
is
> > a patch to export this function?
>
>It's a standard function, is was added less than two years ago.
>You should really consider upgrading to a recent kernel version for
>a number of reasons, but they are all unrelated to your current problem
;-)
>
> Arnd <><
_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-06-08 13:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-06 19:30 a question on "iowrite32()" Ming Liu
2007-06-07 6:20 ` Domen Puncer
2007-06-07 10:01 ` Arnd Bergmann
2007-06-07 11:20 ` Ming Liu
2007-06-07 14:09 ` Arnd Bergmann
2007-06-08 13:51 ` Ming Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox