2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Numascale NumaConnect-Specific Header file
8 * Copyright (C) 2011 Numascale AS. All rights reserved.
10 * Send feedback to <support@numascale.com>
14 #ifndef _ASM_X86_NUMACHIP_NUMACHIP_CSR_H
15 #define _ASM_X86_NUMACHIP_NUMACHIP_CSR_H
19 #define CSR_NODE_SHIFT 16
20 #define CSR_NODE_BITS(p) (((unsigned long)(p)) << CSR_NODE_SHIFT)
21 #define CSR_NODE_MASK 0x0fff /* 4K nodes */
23 /* 32K CSR space, b15 indicates geo/non-geo */
24 #define CSR_OFFSET_MASK 0x7fffUL
25 #define CSR_G0_NODE_IDS (0x008 + (0 << 12))
26 #define CSR_G3_EXT_IRQ_GEN (0x030 + (3 << 12))
29 * Local CSR space starts in global CSR space with "nodeid" = 0xfff0, however
30 * when using the direct mapping on x86_64, both start and size needs to be
31 * aligned with PMD_SIZE which is 2M
33 #define NUMACHIP_LCSR_BASE 0x3ffffe000000ULL
34 #define NUMACHIP_LCSR_LIM 0x3fffffffffffULL
35 #define NUMACHIP_LCSR_SIZE (NUMACHIP_LCSR_LIM - NUMACHIP_LCSR_BASE + 1)
37 static inline void *lcsr_address(unsigned long offset)
39 return __va(NUMACHIP_LCSR_BASE | (1UL << 15) |
40 CSR_NODE_BITS(0xfff0) | (offset & CSR_OFFSET_MASK));
43 static inline unsigned int read_lcsr(unsigned long offset)
45 return swab32(readl(lcsr_address(offset)));
48 static inline void write_lcsr(unsigned long offset, unsigned int val)
50 writel(swab32(val), lcsr_address(offset));
53 #endif /* _ASM_X86_NUMACHIP_NUMACHIP_CSR_H */