From: Wolfgang Denk Date: Mon, 24 Nov 2008 00:04:48 +0100 Subject: [U-Boot] [PATCH-OMAP3] OMAP3: Convert readl/writel and replace hardcoded values In-Reply-To: References: <1227445293-23887-1-git-send-email-dirk.behme@googlemail.com> <20081123151644.983C88361B11@gemini.denx.de> <4929A58A.5060709@googlemail.com> <20081123194721.38AC6834B03F@gemini.denx.de> Message-ID: <20081123230448.EB41F834B03F@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 Graeme, in message you wrote: > > Do you mean to instance the ecc_control struct at a specific memory > location and use writel(0x000, &ptr->ecc_config);? If so, why not Yes - this, and all other blocks of registers. > simply use ptr->ecc_config = 0x0000? Because in general it will not work. You may make it work in many situations by making sure that the poointer has the "volatile" attribute, but depending on CPu propoerties and/or compiler opti- mization this may or may not be sufficient. Please see for example Documentation/volatile-considered-harmful.txt in the Linux kernel tree. The only clean and portable and thus reliable way is to use the (CPU specific) accessor macros or functions. > and replacing: > write_mmcr_byte(SC520_DRCCTL, \ > (read_mmcr_byte(SC520_DRCCTL) & 0xcf) | (val<<4)); > with: > mmcrptr->drcctl = (mmcrptr->drcctl & 0xcf) | (val<<4); > > Is this appropriate? Probably not. Check what the Linux kenrel is doing (but then, x86 may be a poor example; these processors are simply not advanced enough). 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 "Plan to throw one away. You will anyway." - Fred Brooks, "The Mythical Man Month"