[U-Boot] [PATCH-OMAP3] OMAP3: Convert readl/writel and replace hardcoded values

Wolfgang Denk wd at denx.de
Mon Nov 24 00:04:48 CET 2008


Dear Graeme,

in message <d66caabb0811231324q5bcf3076p698840e2f73c0564 at mail.gmail.com> 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"


More information about the U-Boot mailing list