From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Mon, 18 May 2009 20:42:49 +0200 Subject: [U-Boot] [PATCH 01/10] mx27: basic cpu support In-Reply-To: <59b21cf20905180959p4e736d52g566b0e826e17c07a@mail.gmail.com> References: <1241634633-13917-1-git-send-email-yanok@emcraft.com> <1241634633-13917-2-git-send-email-yanok@emcraft.com> <20090506211604.289C483420E8@gemini.denx.de> <4A0B4F9A.8030503@emcraft.com> <20090514081007.AF05C832E416@gemini.denx.de> <4A0BE30F.9070902@emcraft.com> <20090514094212.2E760832E416@gemini.denx.de> <59b21cf20905180959p4e736d52g566b0e826e17c07a@mail.gmail.com> Message-ID: <20090518184249.1A0F4832E416@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Magnus, In message <59b21cf20905180959p4e736d52g566b0e826e17c07a@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_