more low-hanging fruits - kernel, fs, lib signedness
[pv_ops_mirror.git] / include / asm-arm / arch-ns9xxx / hardware.h
blob25600554c4fe7df1d1d3b293a27133a5256ac185
1 /*
2 * include/asm-arm/arch-ns9xxx/hardware.h
4 * Copyright (C) 2006 by Digi International Inc.
5 * All rights reserved.
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
11 #ifndef __ASM_ARCH_HARDWARE_H
12 #define __ASM_ARCH_HARDWARE_H
14 #include <asm/memory.h>
17 * NetSilicon NS9xxx internal mapping:
19 * physical <--> virtual
20 * 0x90000000 - 0x906fffff <--> 0xf9000000 - 0xf96fffff
21 * 0xa0100000 - 0xa0afffff <--> 0xfa100000 - 0xfaafffff
23 #define io_p2v(x) (0xf0000000 \
24 + (((x) & 0xf0000000) >> 4) \
25 + ((x) & 0x00ffffff))
27 #define io_v2p(x) ((((x) & 0x0f000000) << 4) \
28 + ((x) & 0x00ffffff))
30 #define __REGBIT(bit) ((u32)1 << (bit))
31 #define __REGBITS(hbit, lbit) ((((u32)1 << ((hbit) - (lbit) + 1)) - 1) << (lbit))
32 #define __REGVAL(mask, value) (((value) * ((mask) & (-(mask))) & (mask)))
34 #ifndef __ASSEMBLY__
36 # define __REG(x) (*((volatile u32 *)io_p2v((x))))
37 # define __REG2(x, y) (*((volatile u32 *)io_p2v((x)) + (y)))
39 # define __REGB(x) (*((volatile u8 *)io_p2v((x))))
40 # define __REGB2(x) (*((volatile u8 *)io_p2v((x)) + (y)))
42 # define REGSET(var, reg, field, value) \
43 ((var) = (((var) \
44 & ~(reg ## _ ## field & \
45 ~ reg ## _ ## field ## _ ## value)) \
46 | (reg ## _ ## field ## _ ## value)))
48 # define REGSETIM(var, reg, field, value) \
49 ((var) = (((var) \
50 & ~(reg ## _ ## field & \
51 ~(__REGVAL(reg ## _ ## field, value)))) \
52 | (__REGVAL(reg ## _ ## field, value))))
54 # define REGGET(var, reg, field) \
55 ((var & (reg ## _ ## field)) / \
56 ((reg ## _ ## field) & (-(reg ## _ ## field))))
58 #else
60 # define __REG(x) io_p2v(x)
61 # define __REG2(x, y) io_p2v((x) + (y))
63 # define __REGB(x) __REG((x))
64 # define __REGB2(x, y) __REG2((x), (y))
66 #endif
68 #endif /* ifndef __ASM_ARCH_HARDWARE_H */