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
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) \
27 #define io_v2p(x) ((((x) & 0x0f000000) << 4) \
30 #define __REGSHIFT(mask) ((mask) & (-(mask)))
32 #define __REGBIT(bit) ((u32)1 << (bit))
33 #define __REGBITS(hbit, lbit) ((((u32)1 << ((hbit) - (lbit) + 1)) - 1) << (lbit))
34 #define __REGVAL(mask, value) (((value) * __REGSHIFT(mask)) & (mask))
38 # define __REG(x) ((void __iomem __force *)io_p2v((x)))
39 # define __REG2(x, y) ((void __iomem __force *)(io_p2v((x)) + 4 * (y)))
41 # define __REGSET(var, field, value) \
42 ((var) = (((var) & ~((field) & ~(value))) | (value)))
44 # define REGSET(var, reg, field, value) \
45 __REGSET(var, reg ## _ ## field, reg ## _ ## field ## _ ## value)
47 # define REGSET_IDX(var, reg, field, idx, value) \
48 __REGSET(var, reg ## _ ## field((idx)), reg ## _ ## field ## _ ## value((idx)))
50 # define REGSETIM(var, reg, field, value) \
51 __REGSET(var, reg ## _ ## field, __REGVAL(reg ## _ ## field, (value)))
53 # define REGSETIM_IDX(var, reg, field, idx, value) \
54 __REGSET(var, reg ## _ ## field((idx)), __REGVAL(reg ## _ ## field((idx)), (value)))
56 # define __REGGET(var, field) \
59 # define REGGET(var, reg, field) \
60 __REGGET(var, reg ## _ ## field)
62 # define REGGET_IDX(var, reg, field, idx) \
63 __REGGET(var, reg ## _ ## field((idx)))
65 # define REGGETIM(var, reg, field) \
66 __REGGET(var, reg ## _ ## field) / __REGSHIFT(reg ## _ ## field)
68 # define REGGETIM_IDX(var, reg, field, idx) \
69 __REGGET(var, reg ## _ ## field((idx))) / \
70 __REGSHIFT(reg ## _ ## field((idx)))
74 # define __REG(x) io_p2v(x)
75 # define __REG2(x, y) io_p2v((x) + 4 * (y))
79 #endif /* ifndef __ASM_ARCH_HARDWARE_H */