linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Undestanding ioread32() / readl() and friends
@ 2007-02-21  9:50 Florian Boelstler
  2007-02-21  9:56 ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Boelstler @ 2007-02-21  9:50 UTC (permalink / raw)
  To: linuxppc-embedded

Hi,

I just came across include/asm-ppc/io.h, which revealed that ioread32() 
maps to readl(), which in turn maps to in_le32() (when CONFIG_APUS and 
CONFIG_8260_PCI9 are both not defined).
in_le32() uses a asm instruction lwbrx to do byte swapping.

I don't really get why ioread32() effectively returns a little-endian 
value on a big-endian PPCs.

Is this a sort of general rule that ioread32() always returns 
little-endian values on all architectures?

BTW, "Linux Device Drivers, 3rd edition" by Corbet et al states that 
ioread32() does not perform any endian conversion.
May be they are based on x86...

Thanks,

   Florian

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

* Re: Undestanding ioread32() / readl() and friends
  2007-02-21  9:50 Undestanding ioread32() / readl() and friends Florian Boelstler
@ 2007-02-21  9:56 ` Arnd Bergmann
  2007-02-21 14:33   ` Florian Boelstler
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2007-02-21  9:56 UTC (permalink / raw)
  To: linuxppc-embedded

On Wednesday 21 February 2007 10:50, Florian Boelstler wrote:
> I just came across include/asm-ppc/io.h, which revealed that ioread32() 
> maps to readl(), which in turn maps to in_le32() (when CONFIG_APUS and 
> CONFIG_8260_PCI9 are both not defined).
> in_le32() uses a asm instruction lwbrx to do byte swapping.
> 
> I don't really get why ioread32() effectively returns a little-endian 
> value on a big-endian PPCs.
> 
> Is this a sort of general rule that ioread32() always returns 
> little-endian values on all architectures?

the ioread family of functions is used for PCI devices, which
are little-endian by definition.

If you want to access on-chip devices that are not behind PCI,
you should use the in_be family of functions.

	Arnd <><

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

* Re: Undestanding ioread32() / readl() and friends
  2007-02-21  9:56 ` Arnd Bergmann
@ 2007-02-21 14:33   ` Florian Boelstler
  0 siblings, 0 replies; 3+ messages in thread
From: Florian Boelstler @ 2007-02-21 14:33 UTC (permalink / raw)
  To: linuxppc-embedded

Hi,

Arnd Bergmann schrieb:
>> Is this a sort of general rule that ioread32() always returns 
>> little-endian values on all architectures?
> 
> the ioread family of functions is used for PCI devices, which
> are little-endian by definition.

OK, my knowledge about ioread32() was based on some explanations found 
in "Linux Device Drivers". IMHO they showed the ioread family of 
functions as a sort of general purpose functions for __iomem-alike 
resources.

Thanks, anyway.

   Florian

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

end of thread, other threads:[~2007-02-21 14:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-21  9:50 Undestanding ioread32() / readl() and friends Florian Boelstler
2007-02-21  9:56 ` Arnd Bergmann
2007-02-21 14:33   ` Florian Boelstler

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