[U-Boot] [PATCH 01/10] mx27: basic cpu support

Wolfgang Denk wd at denx.de
Mon May 18 20:42:49 CEST 2009


Dear Magnus,

In message <59b21cf20905180959p4e736d52g566b0e826e17c07a at mail.gmail.com> you wrote:
> 
> After having browsed some powerpc code I can find two different ways
> the struct-thing is used:
> Variant A, all members declared volatile:
> struct controller_reg {
>   volatile uint32_t reg1;
>   volatile uint32_t reg2;
> }

This is probably older code.

> struct controller_reg *controller = 0xCAFE0000;
> 
> Or variant B:
> struct controller_reg {
>   uint32_t reg1;
>   uint32_t reg2;
> }

This is OK.

> volatile struct controller_reg *controller = 0xCAFE0000;
> 
> Also, is it OK to access the registers using reg = controller->reg1 or

No.

> should we use reg = readl(&controller->reg1)?

Yes. All device acesses should use proper I/O accessor calls.

Note though that readl() is not considered to be portable; at least
not across architectures. In Linux the ioread() / iowrite() are
considered portable and should be used, i. e. ioread16(),
ioread16be(), ioread32(), ioread32be() etc. - the plain ioread*()
[i. e. without the "be" part] being little-endian on all
architectures.


I am aware that we don't have appropriate support for all of this in
the standard header files yet (actually I don't think Linu xhas this
yet, either).

But that's the theory. Or at least the intersection of what I've been
told, what I understood and what I still remember ;-)

> I ask this since I don't want to iterate the patches on the mailing
> list too many times...

Good luck!

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
In the beginning, there was nothing, which exploded.
                                - Terry Pratchett, _Lords and Ladies_


More information about the U-Boot mailing list