linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* RE: Yosemite/440EP why are readl()/ioread32() setup to readlittle-endian?
@ 2006-02-02  9:35 Jenkins, Clive
  2006-02-02  9:46 ` Eugene Surovegin
  0 siblings, 1 reply; 51+ messages in thread
From: Jenkins, Clive @ 2006-02-02  9:35 UTC (permalink / raw)
  To: Eugene Surovegin, Peter Korsgaard; +Cc: linuxppc-embedded

A driver for some device that could be connected to (or plugged into)
a variety of different platforms of different architecture.
A driver for a core that could be implemented within an FPGA on
multiple platforms.

Clive

-----Original Message-----
From: Eugene Surovegin [mailto:ebs@ebshome.net]=20
Sent: 02 February 2006 09:08
To: Peter Korsgaard
Cc: Kumar Gala; linuxppc-embedded@ozlabs.org; Jenkins, Clive
Subject: Re: Yosemite/440EP why are readl()/ioread32() setup to
readlittle-endian?


On Thu, Feb 02, 2006 at 09:09:17AM +0100, Peter Korsgaard wrote:
> On 2/2/06, Kumar Gala <galak@kernel.crashing.org> wrote:
> > > What is the preferred way of accessing non-PCI devices then?
Direct
> > > pointer access?
> >
> > No direct pointer access is bad. On PPC You can use
> > in_be{8,16,32}/out_be{8,16,32}
>=20
> What about arch independent drivers? Are there any generic approach
> for this or do you have to stick to ugly #ifdefs to decide between
> in_be32/inl ?

I'm curious, could you give an example of such arch independent=20
driver?

--=20
Eugene

^ permalink raw reply	[flat|nested] 51+ messages in thread
* RE: Yosemite/440EP why are readl()/ioread32() setup to readlittle-endian?
@ 2006-02-01 18:35 Jenkins, Clive
  2006-02-01 20:35 ` David Hawkins
  0 siblings, 1 reply; 51+ messages in thread
From: Jenkins, Clive @ 2006-02-01 18:35 UTC (permalink / raw)
  To: David Hawkins; +Cc: linuxppc-embedded

>>>p453 of his book has a PCI DMA example, where he uses the
>>>cpu_to_le32() macros inside calls writel().

>>>However, since these functions are internally implemented to
>>>perform LE operations, this example appears to be incorrect.

>>>Would you agree?
=20
>> No, I think it is correct.

I said this without looking up the example you cited.
I agree now, the example is incorrect; and yes, file a bug
report at oreilly!

I think, from memory, that elsewhere in the book Rubini does
say that readl()... are for the PCI bus, but cross-arch issues
are only addressed in certain sections.

I always find out exactly what these macros do on the arch
I am using, then I know where I stand. I find LXR (Google it if
you don't know it) good for browsing the source of vanilla
kernels. After finding out how and where it is done, I then
double check the relevant files of the actual kernel I am using.

ppc implementations of readl, writel, cpu_to_le32 use the byte-
reversed load/store word instructions.

Clive

^ permalink raw reply	[flat|nested] 51+ messages in thread
* RE: Yosemite/440EP why are readl()/ioread32() setup to readlittle-endian?
@ 2006-02-01 11:19 Jenkins, Clive
  2006-02-01 17:02 ` David Hawkins
  0 siblings, 1 reply; 51+ messages in thread
From: Jenkins, Clive @ 2006-02-01 11:19 UTC (permalink / raw)
  To: David Hawkins, Stefan Roese; +Cc: linuxppc-embedded

> >>readl() and ioread32() read the registers in little-endian format!
> >
> > Correct. That's how it is implemented on all platforms. Think for
> > example of an pci device driver. Using these IO functions, the
> > driver will become platform independent, running without
> > modifications on little- and big-endian machines.
>
> I just stumbled across the section in Rubini 3rd Ed that mislead
> me into believing that the readl()/writel() were machine endianness
> dependent, i.e., LE on x86, BE on PPC.

> p453 of his book has a PCI DMA example, where he uses the
> cpu_to_le32() macros inside calls writel().

> However, since these functions are internally implemented to
> perform LE operations, this example appears to be incorrect.

> Would you agree?

No, I think it is correct.

On most architectures readl() and writel() assume you are
accessing MMIO on the PCI bus, which is little-endian.
So these macros convert between the endian-ness of the CPU
and the endian-ness of the PCI bus.

Clive

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

end of thread, other threads:[~2006-02-11 19:02 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-02  9:35 Yosemite/440EP why are readl()/ioread32() setup to readlittle-endian? Jenkins, Clive
2006-02-02  9:46 ` Eugene Surovegin
2006-02-02 14:37   ` Matt Porter
2006-02-02 17:45     ` Eugene Surovegin
2006-02-02 18:16       ` Matt Porter
2006-02-05  4:41         ` Yosemite/440EP PLB4 vs PLB3 DMA to PCI issue David Hawkins
2006-02-05 10:39           ` Wolfgang Denk
2006-02-05 23:47             ` David Hawkins
2006-02-06 18:31               ` Stefan Roese
2006-02-06 19:09                 ` David Hawkins
2006-02-08 15:38                   ` Stefan Roese
2006-02-08 18:43                     ` David Hawkins
2006-02-09  0:34                       ` Wolfgang Denk
2006-02-09 13:25                         ` Mark Chambers
2006-02-09 23:58                         ` Yosemite/440EP 'issues' as a PCI target David Hawkins
2006-02-10  7:47                           ` Stefan Roese
2006-02-10 17:05                             ` David Hawkins
2006-02-10 17:20                               ` Andrew Armitage
2006-02-10 17:26                                 ` David Hawkins
2006-02-10 17:31                               ` Wolfgang Denk
2006-02-10 17:38                                 ` David Hawkins
2006-02-10 17:58                                   ` David Hawkins
2006-02-11  6:03                                 ` David Hawkins
2006-02-11  8:21                                   ` Stefan Roese
2006-02-11 18:15                                     ` David Hawkins
2006-02-11 13:03                                   ` Wolfgang Denk
2006-02-10 17:59                               ` Stefan Roese
2006-02-10 18:11                                 ` David Hawkins
2006-02-11  8:06                                   ` Stefan Roese
2006-02-11 18:06                                     ` David Hawkins
2006-02-11 19:00                                     ` David Hawkins
     [not found]                               ` <001701c62e6c$09c48ea0$6401a8c0@CHUCK2>
2006-02-10 18:19                                 ` David Hawkins
2006-02-11  6:06                                 ` David Hawkins
     [not found]                               ` <43ECCCA2.1070007@sandburst.com>
     [not found]                                 ` <43ECCE7A.4090507@ovro.caltech.edu>
     [not found]                                   ` <43ECD19E.8010604@sandburst.com>
2006-02-10 19:13                                     ` David Hawkins
  -- strict thread matches above, loose matches on Subject: below --
2006-02-01 18:35 Yosemite/440EP why are readl()/ioread32() setup to readlittle-endian? Jenkins, Clive
2006-02-01 20:35 ` David Hawkins
2006-02-01 11:19 Jenkins, Clive
2006-02-01 17:02 ` David Hawkins
2006-02-01 17:44   ` Matt Porter
2006-02-01 17:53     ` David Hawkins
2006-02-01 18:04     ` David Hawkins
2006-02-01 18:11       ` Eugene Surovegin
2006-02-01 18:20         ` David Hawkins
2006-02-01 18:23           ` Eugene Surovegin
2006-02-01 21:14     ` Peter Korsgaard
2006-02-02  0:54       ` Kumar Gala
2006-02-02  3:07         ` Matt Porter
2006-02-02  8:09         ` Peter Korsgaard
2006-02-02  9:08           ` Eugene Surovegin
2006-02-02 17:34             ` Dale Farnsworth
2006-02-02 14:21           ` Matt Porter

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