Dear Magnus, In message <59b21cf20905180959p4e736d52g566b0e826e17c...@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: w...@denx.de In the beginning, there was nothing, which exploded. - Terry Pratchett, _Lords and Ladies_ _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot