Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 1 | /* |
| 2 | * include/asm-arm/arch-ns9xxx/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 | #include <asm/memory.h> |
| 15 | |
| 16 | /* |
| 17 | * NetSilicon NS9xxx internal mapping: |
| 18 | * |
| 19 | * physical <--> virtual |
| 20 | * 0x90000000 - 0x906fffff <--> 0xf9000000 - 0xf96fffff |
| 21 | * 0xa0100000 - 0xa0afffff <--> 0xfa100000 - 0xfaafffff |
| 22 | */ |
| 23 | #define io_p2v(x) (0xf0000000 \ |
| 24 | + (((x) & 0xf0000000) >> 4) \ |
| 25 | + ((x) & 0x00ffffff)) |
| 26 | |
| 27 | #define io_v2p(x) ((((x) & 0x0f000000) << 4) \ |
| 28 | + ((x) & 0x00ffffff)) |
| 29 | |
Uwe Kleine-König | f02e579 | 2007-09-30 20:35:27 +0100 | [diff] [blame] | 30 | #define __REGSHIFT(mask) ((mask) & (-(mask))) |
| 31 | |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 32 | #define __REGBIT(bit) ((u32)1 << (bit)) |
| 33 | #define __REGBITS(hbit, lbit) ((((u32)1 << ((hbit) - (lbit) + 1)) - 1) << (lbit)) |
Uwe Kleine-König | f02e579 | 2007-09-30 20:35:27 +0100 | [diff] [blame] | 34 | #define __REGVAL(mask, value) (((value) * __REGSHIFT(mask)) & (mask)) |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 35 | |
| 36 | #ifndef __ASSEMBLY__ |
| 37 | |
| 38 | # define __REG(x) (*((volatile u32 *)io_p2v((x)))) |
| 39 | # define __REG2(x, y) (*((volatile u32 *)io_p2v((x)) + (y))) |
| 40 | |
| 41 | # define __REGB(x) (*((volatile u8 *)io_p2v((x)))) |
| 42 | # define __REGB2(x) (*((volatile u8 *)io_p2v((x)) + (y))) |
| 43 | |
Uwe Kleine-König | f02e579 | 2007-09-30 20:35:27 +0100 | [diff] [blame] | 44 | # define __REGSET(var, field, value) \ |
| 45 | ((var) = (((var) & ~((field) & ~(value))) | (value))) |
| 46 | |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 47 | # define REGSET(var, reg, field, value) \ |
Uwe Kleine-König | f02e579 | 2007-09-30 20:35:27 +0100 | [diff] [blame] | 48 | __REGSET(var, reg ## _ ## field, reg ## _ ## field ## _ ## value) |
| 49 | |
| 50 | # define REGSET_IDX(var, reg, field, idx, value) \ |
| 51 | __REGSET(var, reg ## _ ## field((idx)), reg ## _ ## field ## _ ## value((idx))) |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 52 | |
| 53 | # define REGSETIM(var, reg, field, value) \ |
Uwe Kleine-König | f02e579 | 2007-09-30 20:35:27 +0100 | [diff] [blame] | 54 | __REGSET(var, reg ## _ ## field, __REGVAL(reg ## _ ## field, (value))) |
| 55 | |
| 56 | # define REGSETIM_IDX(var, reg, field, idx, value) \ |
| 57 | __REGSET(var, reg ## _ ## field((idx)), __REGVAL(reg ## _ ## field((idx)), (value))) |
| 58 | |
| 59 | # define __REGGET(var, field) \ |
| 60 | (((var) & (field))) |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 61 | |
Uwe Kleine-König | fee64d1 | 2007-03-28 17:18:30 +0100 | [diff] [blame] | 62 | # define REGGET(var, reg, field) \ |
Uwe Kleine-König | f02e579 | 2007-09-30 20:35:27 +0100 | [diff] [blame] | 63 | __REGGET(var, reg ## _ ## field) |
| 64 | |
| 65 | # define REGGET_IDX(var, reg, field, idx) \ |
| 66 | __REGGET(var, reg ## _ ## field((idx))) |
| 67 | |
| 68 | # define REGGETIM(var, reg, field) \ |
| 69 | __REGGET(var, reg ## _ ## field) / __REGSHIFT(reg ## _ ## field) |
| 70 | |
| 71 | # define REGGETIM_IDX(var, reg, field, idx) \ |
| 72 | __REGGET(var, reg ## _ ## field((idx))) / \ |
| 73 | __REGSHIFT(reg ## _ ## field((idx))) |
Uwe Kleine-König | 9918cda | 2007-02-16 15:36:55 +0100 | [diff] [blame] | 74 | |
| 75 | #else |
| 76 | |
| 77 | # define __REG(x) io_p2v(x) |
| 78 | # define __REG2(x, y) io_p2v((x) + (y)) |
| 79 | |
| 80 | # define __REGB(x) __REG((x)) |
| 81 | # define __REGB2(x, y) __REG2((x), (y)) |
| 82 | |
| 83 | #endif |
| 84 | |
| 85 | #endif /* ifndef __ASM_ARCH_HARDWARE_H */ |