diff options
author | Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de> | 2007-09-30 20:35:27 +0100 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2007-10-12 23:43:36 +0100 |
commit | f02e579558cf2aba06ecc7d4515661286b60f411 (patch) | |
tree | 2c4846eb64c3bd330275a183b9d8244ab075e7a0 /include/asm-arm/arch-ns9xxx | |
parent | 689f2a01e68c0033f59055dd816ff27dc51f9dcc (diff) |
[ARM] 4591/1: ns9xxx: simplify REGSET, REGGET and introduce ..._IDX variants
The semantic of the REGSET macros didn't change, but hopefully
it's more obvious as it's now.
REGGET is changed to return the unshifted value, analogous to
REGSET. REGGETIM behaves as REGGET before. All callers changed.
..._IDX is used to work with registers that need a parameter like
BBU_GCONFb1.
Signed-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'include/asm-arm/arch-ns9xxx')
-rw-r--r-- | include/asm-arm/arch-ns9xxx/clock.h | 4 | ||||
-rw-r--r-- | include/asm-arm/arch-ns9xxx/hardware.h | 39 |
2 files changed, 30 insertions, 13 deletions
diff --git a/include/asm-arm/arch-ns9xxx/clock.h b/include/asm-arm/arch-ns9xxx/clock.h index bf30cbdcc2bf..90604d48d561 100644 --- a/include/asm-arm/arch-ns9xxx/clock.h +++ b/include/asm-arm/arch-ns9xxx/clock.h @@ -46,8 +46,8 @@ static inline u32 ns9xxx_systemclock(void) * * Fine. */ - return CRYSTAL * (REGGET(pll, SYS_PLL, ND) + 1) - >> REGGET(pll, SYS_PLL, FS); + return CRYSTAL * (REGGETIM(pll, SYS_PLL, ND) + 1) + >> REGGETIM(pll, SYS_PLL, FS); } static inline u32 ns9xxx_cpuclock(void) __attribute__((const)); diff --git a/include/asm-arm/arch-ns9xxx/hardware.h b/include/asm-arm/arch-ns9xxx/hardware.h index 25600554c4fe..b5d66f963981 100644 --- a/include/asm-arm/arch-ns9xxx/hardware.h +++ b/include/asm-arm/arch-ns9xxx/hardware.h @@ -27,9 +27,11 @@ #define io_v2p(x) ((((x) & 0x0f000000) << 4) \ + ((x) & 0x00ffffff)) +#define __REGSHIFT(mask) ((mask) & (-(mask))) + #define __REGBIT(bit) ((u32)1 << (bit)) #define __REGBITS(hbit, lbit) ((((u32)1 << ((hbit) - (lbit) + 1)) - 1) << (lbit)) -#define __REGVAL(mask, value) (((value) * ((mask) & (-(mask))) & (mask))) +#define __REGVAL(mask, value) (((value) * __REGSHIFT(mask)) & (mask)) #ifndef __ASSEMBLY__ @@ -39,21 +41,36 @@ # define __REGB(x) (*((volatile u8 *)io_p2v((x)))) # define __REGB2(x) (*((volatile u8 *)io_p2v((x)) + (y))) +# define __REGSET(var, field, value) \ + ((var) = (((var) & ~((field) & ~(value))) | (value))) + # define REGSET(var, reg, field, value) \ - ((var) = (((var) \ - & ~(reg ## _ ## field & \ - ~ reg ## _ ## field ## _ ## value)) \ - | (reg ## _ ## field ## _ ## value))) + __REGSET(var, reg ## _ ## field, reg ## _ ## field ## _ ## value) + +# define REGSET_IDX(var, reg, field, idx, value) \ + __REGSET(var, reg ## _ ## field((idx)), reg ## _ ## field ## _ ## value((idx))) # define REGSETIM(var, reg, field, value) \ - ((var) = (((var) \ - & ~(reg ## _ ## field & \ - ~(__REGVAL(reg ## _ ## field, value)))) \ - | (__REGVAL(reg ## _ ## field, value)))) + __REGSET(var, reg ## _ ## field, __REGVAL(reg ## _ ## field, (value))) + +# define REGSETIM_IDX(var, reg, field, idx, value) \ + __REGSET(var, reg ## _ ## field((idx)), __REGVAL(reg ## _ ## field((idx)), (value))) + +# define __REGGET(var, field) \ + (((var) & (field))) # define REGGET(var, reg, field) \ - ((var & (reg ## _ ## field)) / \ - ((reg ## _ ## field) & (-(reg ## _ ## field)))) + __REGGET(var, reg ## _ ## field) + +# define REGGET_IDX(var, reg, field, idx) \ + __REGGET(var, reg ## _ ## field((idx))) + +# define REGGETIM(var, reg, field) \ + __REGGET(var, reg ## _ ## field) / __REGSHIFT(reg ## _ ## field) + +# define REGGETIM_IDX(var, reg, field, idx) \ + __REGGET(var, reg ## _ ## field((idx))) / \ + __REGSHIFT(reg ## _ ## field((idx))) #else |