1 /* 2 * arch/arm/mach-ns9xxx/include/mach/hardware.h 3 * 4 * Copyright (C) 2006 by Digi International Inc. 5 * All rights reserved. 6 * 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. 10 */ 11 #ifndef __ASM_ARCH_HARDWARE_H 12 #define __ASM_ARCH_HARDWARE_H 13 14 /* 15 * NetSilicon NS9xxx internal mapping: 16 * 17 * physical <--> virtual 18 * 0x90000000 - 0x906fffff <--> 0xf9000000 - 0xf96fffff 19 * 0xa0100000 - 0xa0afffff <--> 0xfa100000 - 0xfaafffff 20 */ 21 #define io_p2v(x) (0xf0000000 \ 22 + (((x) & 0xf0000000) >> 4) \ 23 + ((x) & 0x00ffffff)) 24 25 #define io_v2p(x) ((((x) & 0x0f000000) << 4) \ 26 + ((x) & 0x00ffffff)) 27 28 #define __REGSHIFT(mask) ((mask) & (-(mask))) 29 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)) 33 34 #ifndef __ASSEMBLY__ 35 36 # define __REG(x) ((void __iomem __force *)io_p2v((x))) 37 # define __REG2(x, y) ((void __iomem __force *)(io_p2v((x)) + 4 * (y))) 38 39 # define __REGSET(var, field, value) \ 40 ((var) = (((var) & ~((field) & ~(value))) | (value))) 41 42 # define REGSET(var, reg, field, value) \ 43 __REGSET(var, reg ## _ ## field, reg ## _ ## field ## _ ## value) 44 45 # define REGSET_IDX(var, reg, field, idx, value) \ 46 __REGSET(var, reg ## _ ## field((idx)), reg ## _ ## field ## _ ## value((idx))) 47 48 # define REGSETIM(var, reg, field, value) \ 49 __REGSET(var, reg ## _ ## field, __REGVAL(reg ## _ ## field, (value))) 50 51 # define REGSETIM_IDX(var, reg, field, idx, value) \ 52 __REGSET(var, reg ## _ ## field((idx)), __REGVAL(reg ## _ ## field((idx)), (value))) 53 54 # define __REGGET(var, field) \ 55 (((var) & (field))) 56 57 # define REGGET(var, reg, field) \ 58 __REGGET(var, reg ## _ ## field) 59 60 # define REGGET_IDX(var, reg, field, idx) \ 61 __REGGET(var, reg ## _ ## field((idx))) 62 63 # define REGGETIM(var, reg, field) \ 64 __REGGET(var, reg ## _ ## field) / __REGSHIFT(reg ## _ ## field) 65 66 # define REGGETIM_IDX(var, reg, field, idx) \ 67 __REGGET(var, reg ## _ ## field((idx))) / \ 68 __REGSHIFT(reg ## _ ## field((idx))) 69 70 #else 71 72 # define __REG(x) io_p2v(x) 73 # define __REG2(x, y) io_p2v((x) + 4 * (y)) 74 75 #endif 76 77 #endif /* ifndef __ASM_ARCH_HARDWARE_H */ 78