
On Mon, May 18, 2009 at 06:59:18PM +0200, Magnus Lilja 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; }
struct controller_reg *controller = 0xCAFE0000;
Or variant B: struct controller_reg { uint32_t reg1; uint32_t reg2; }
volatile struct controller_reg *controller = 0xCAFE0000;
Those are both deprecated. There should be no volatile, and you should use I/O accessors instead.
Also, is it OK to access the registers using reg = controller->reg1 or should we use reg = readl(&controller->reg1)?
The latter. Note that readl is supposed to be little-endian regardless of host endianness, though ARM's io.h looks a bit weird (there are multiple definitions of readl protected by ifdefs, and the normal one does no swapping -- and __mem_pci looks like it would result in a name conflict). On powerpc we have accessors with explicit endianness.
-Scott