diff options
Diffstat (limited to 'include/asm-arm/arch-ns9xxx/hardware.h')
-rw-r--r-- | include/asm-arm/arch-ns9xxx/hardware.h | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/include/asm-arm/arch-ns9xxx/hardware.h b/include/asm-arm/arch-ns9xxx/hardware.h index 25600554c4fe..0b7b34603f1c 100644 --- a/include/asm-arm/arch-ns9xxx/hardware.h +++ b/include/asm-arm/arch-ns9xxx/hardware.h | |||
@@ -27,42 +27,53 @@ | |||
27 | #define io_v2p(x) ((((x) & 0x0f000000) << 4) \ | 27 | #define io_v2p(x) ((((x) & 0x0f000000) << 4) \ |
28 | + ((x) & 0x00ffffff)) | 28 | + ((x) & 0x00ffffff)) |
29 | 29 | ||
30 | #define __REGSHIFT(mask) ((mask) & (-(mask))) | ||
31 | |||
30 | #define __REGBIT(bit) ((u32)1 << (bit)) | 32 | #define __REGBIT(bit) ((u32)1 << (bit)) |
31 | #define __REGBITS(hbit, lbit) ((((u32)1 << ((hbit) - (lbit) + 1)) - 1) << (lbit)) | 33 | #define __REGBITS(hbit, lbit) ((((u32)1 << ((hbit) - (lbit) + 1)) - 1) << (lbit)) |
32 | #define __REGVAL(mask, value) (((value) * ((mask) & (-(mask))) & (mask))) | 34 | #define __REGVAL(mask, value) (((value) * __REGSHIFT(mask)) & (mask)) |
33 | 35 | ||
34 | #ifndef __ASSEMBLY__ | 36 | #ifndef __ASSEMBLY__ |
35 | 37 | ||
36 | # define __REG(x) (*((volatile u32 *)io_p2v((x)))) | 38 | # define __REG(x) ((void __iomem __force *)io_p2v((x))) |
37 | # define __REG2(x, y) (*((volatile u32 *)io_p2v((x)) + (y))) | 39 | # define __REG2(x, y) ((void __iomem __force *)(io_p2v((x)) + 4 * (y))) |
38 | 40 | ||
39 | # define __REGB(x) (*((volatile u8 *)io_p2v((x)))) | 41 | # define __REGSET(var, field, value) \ |
40 | # define __REGB2(x) (*((volatile u8 *)io_p2v((x)) + (y))) | 42 | ((var) = (((var) & ~((field) & ~(value))) | (value))) |
41 | 43 | ||
42 | # define REGSET(var, reg, field, value) \ | 44 | # define REGSET(var, reg, field, value) \ |
43 | ((var) = (((var) \ | 45 | __REGSET(var, reg ## _ ## field, reg ## _ ## field ## _ ## value) |
44 | & ~(reg ## _ ## field & \ | 46 | |
45 | ~ reg ## _ ## field ## _ ## value)) \ | 47 | # define REGSET_IDX(var, reg, field, idx, value) \ |
46 | | (reg ## _ ## field ## _ ## value))) | 48 | __REGSET(var, reg ## _ ## field((idx)), reg ## _ ## field ## _ ## value((idx))) |
47 | 49 | ||
48 | # define REGSETIM(var, reg, field, value) \ | 50 | # define REGSETIM(var, reg, field, value) \ |
49 | ((var) = (((var) \ | 51 | __REGSET(var, reg ## _ ## field, __REGVAL(reg ## _ ## field, (value))) |
50 | & ~(reg ## _ ## field & \ | 52 | |
51 | ~(__REGVAL(reg ## _ ## field, value)))) \ | 53 | # define REGSETIM_IDX(var, reg, field, idx, value) \ |
52 | | (__REGVAL(reg ## _ ## field, value)))) | 54 | __REGSET(var, reg ## _ ## field((idx)), __REGVAL(reg ## _ ## field((idx)), (value))) |
55 | |||
56 | # define __REGGET(var, field) \ | ||
57 | (((var) & (field))) | ||
53 | 58 | ||
54 | # define REGGET(var, reg, field) \ | 59 | # define REGGET(var, reg, field) \ |
55 | ((var & (reg ## _ ## field)) / \ | 60 | __REGGET(var, reg ## _ ## field) |
56 | ((reg ## _ ## field) & (-(reg ## _ ## field)))) | 61 | |
62 | # define REGGET_IDX(var, reg, field, idx) \ | ||
63 | __REGGET(var, reg ## _ ## field((idx))) | ||
64 | |||
65 | # define REGGETIM(var, reg, field) \ | ||
66 | __REGGET(var, reg ## _ ## field) / __REGSHIFT(reg ## _ ## field) | ||
67 | |||
68 | # define REGGETIM_IDX(var, reg, field, idx) \ | ||
69 | __REGGET(var, reg ## _ ## field((idx))) / \ | ||
70 | __REGSHIFT(reg ## _ ## field((idx))) | ||
57 | 71 | ||
58 | #else | 72 | #else |
59 | 73 | ||
60 | # define __REG(x) io_p2v(x) | 74 | # define __REG(x) io_p2v(x) |
61 | # define __REG2(x, y) io_p2v((x) + (y)) | 75 | # define __REG2(x, y) io_p2v((x) + (y)) |
62 | 76 | ||
63 | # define __REGB(x) __REG((x)) | ||
64 | # define __REGB2(x, y) __REG2((x), (y)) | ||
65 | |||
66 | #endif | 77 | #endif |
67 | 78 | ||
68 | #endif /* ifndef __ASM_ARCH_HARDWARE_H */ | 79 | #endif /* ifndef __ASM_ARCH_HARDWARE_H */ |