2 * arch/arm/mach-ns9xxx/include/mach/hardware.h
4 * Copyright (C) 2006 by Digi International Inc.
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
15 * NetSilicon NS9xxx internal mapping:
17 * physical <--> virtual
18 * 0x90000000 - 0x906fffff <--> 0xf9000000 - 0xf96fffff
19 * 0xa0100000 - 0xa0afffff <--> 0xfa100000 - 0xfaafffff
21 #define io_p2v(x) (0xf0000000 \
22 + (((x) & 0xf0000000) >> 4) \
25 #define io_v2p(x) ((((x) & 0x0f000000) << 4) \
28 #define __REGSHIFT(mask) ((mask) & (-(mask)))
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) * __REGSHIFT(mask)) & (mask))
36 # define __REG(x) ((void __iomem __force *)io_p2v((x)))
37 # define __REG2(x, y) ((void __iomem __force *)(io_p2v((x)) + 4 * (y)))
39 # define __REGSET(var, field, value) \
40 ((var) = (((var) & ~((field) & ~(value))) | (value)))
42 # define REGSET(var, reg, field, value) \
43 __REGSET(var, reg ## _ ## field, reg ## _ ## field ## _ ## value)
45 # define REGSET_IDX(var, reg, field, idx, value) \
46 __REGSET(var, reg ## _ ## field((idx)), reg ## _ ## field ## _ ## value((idx)))
48 # define REGSETIM(var, reg, field, value) \
49 __REGSET(var, reg ## _ ## field, __REGVAL(reg ## _ ## field, (value)))
51 # define REGSETIM_IDX(var, reg, field, idx, value) \
52 __REGSET(var, reg ## _ ## field((idx)), __REGVAL(reg ## _ ## field((idx)), (value)))
54 # define __REGGET(var, field) \
57 # define REGGET(var, reg, field) \
58 __REGGET(var, reg ## _ ## field)
60 # define REGGET_IDX(var, reg, field, idx) \
61 __REGGET(var, reg ## _ ## field((idx)))
63 # define REGGETIM(var, reg, field) \
64 __REGGET(var, reg ## _ ## field) / __REGSHIFT(reg ## _ ## field)
66 # define REGGETIM_IDX(var, reg, field, idx) \
67 __REGGET(var, reg ## _ ## field((idx))) / \
68 __REGSHIFT(reg ## _ ## field((idx)))
72 # define __REG(x) io_p2v(x)
73 # define __REG2(x, y) io_p2v((x) + 4 * (y))
77 #endif /* ifndef __ASM_ARCH_HARDWARE_H */