144b111b5SSteffen Persvold /* 244b111b5SSteffen Persvold * This file is subject to the terms and conditions of the GNU General Public 344b111b5SSteffen Persvold * License. See the file "COPYING" in the main directory of this archive 444b111b5SSteffen Persvold * for more details. 544b111b5SSteffen Persvold * 644b111b5SSteffen Persvold * Numascale NumaConnect-Specific Header file 744b111b5SSteffen Persvold * 844b111b5SSteffen Persvold * Copyright (C) 2011 Numascale AS. All rights reserved. 944b111b5SSteffen Persvold * 1044b111b5SSteffen Persvold * Send feedback to <support@numascale.com> 1144b111b5SSteffen Persvold * 1244b111b5SSteffen Persvold */ 1344b111b5SSteffen Persvold 1444b111b5SSteffen Persvold #ifndef _ASM_X86_NUMACHIP_NUMACHIP_CSR_H 1544b111b5SSteffen Persvold #define _ASM_X86_NUMACHIP_NUMACHIP_CSR_H 1644b111b5SSteffen Persvold 17d9d4dee6SDaniel J Blueman #include <linux/smp.h> 1844b111b5SSteffen Persvold #include <linux/io.h> 1944b111b5SSteffen Persvold 2044b111b5SSteffen Persvold #define CSR_NODE_SHIFT 16 2144b111b5SSteffen Persvold #define CSR_NODE_BITS(p) (((unsigned long)(p)) << CSR_NODE_SHIFT) 2244b111b5SSteffen Persvold #define CSR_NODE_MASK 0x0fff /* 4K nodes */ 2344b111b5SSteffen Persvold 2444b111b5SSteffen Persvold /* 32K CSR space, b15 indicates geo/non-geo */ 2544b111b5SSteffen Persvold #define CSR_OFFSET_MASK 0x7fffUL 26db1003a7SDaniel J Blueman #define CSR_G0_NODE_IDS (0x008 + (0 << 12)) 27db1003a7SDaniel J Blueman #define CSR_G3_EXT_IRQ_GEN (0x030 + (3 << 12)) 2844b111b5SSteffen Persvold 2944b111b5SSteffen Persvold /* 3044b111b5SSteffen Persvold * Local CSR space starts in global CSR space with "nodeid" = 0xfff0, however 3144b111b5SSteffen Persvold * when using the direct mapping on x86_64, both start and size needs to be 3244b111b5SSteffen Persvold * aligned with PMD_SIZE which is 2M 3344b111b5SSteffen Persvold */ 3444b111b5SSteffen Persvold #define NUMACHIP_LCSR_BASE 0x3ffffe000000ULL 3544b111b5SSteffen Persvold #define NUMACHIP_LCSR_LIM 0x3fffffffffffULL 3644b111b5SSteffen Persvold #define NUMACHIP_LCSR_SIZE (NUMACHIP_LCSR_LIM - NUMACHIP_LCSR_BASE + 1) 37ad03a9c2SDaniel J Blueman #define NUMACHIP_LAPIC_BITS 8 3844b111b5SSteffen Persvold 3944b111b5SSteffen Persvold static inline void *lcsr_address(unsigned long offset) 4044b111b5SSteffen Persvold { 4144b111b5SSteffen Persvold return __va(NUMACHIP_LCSR_BASE | (1UL << 15) | 4244b111b5SSteffen Persvold CSR_NODE_BITS(0xfff0) | (offset & CSR_OFFSET_MASK)); 4344b111b5SSteffen Persvold } 4444b111b5SSteffen Persvold 4544b111b5SSteffen Persvold static inline unsigned int read_lcsr(unsigned long offset) 4644b111b5SSteffen Persvold { 4744b111b5SSteffen Persvold return swab32(readl(lcsr_address(offset))); 4844b111b5SSteffen Persvold } 4944b111b5SSteffen Persvold 5044b111b5SSteffen Persvold static inline void write_lcsr(unsigned long offset, unsigned int val) 5144b111b5SSteffen Persvold { 5244b111b5SSteffen Persvold writel(swab32(val), lcsr_address(offset)); 5344b111b5SSteffen Persvold } 5444b111b5SSteffen Persvold 55d9d4dee6SDaniel J Blueman /* 56d9d4dee6SDaniel J Blueman * On NumaChip2, local CSR space is 16MB and starts at fixed offset below 4G 57d9d4dee6SDaniel J Blueman */ 58d9d4dee6SDaniel J Blueman 59d9d4dee6SDaniel J Blueman #define NUMACHIP2_LCSR_BASE 0xf0000000UL 60d9d4dee6SDaniel J Blueman #define NUMACHIP2_LCSR_SIZE 0x1000000UL 61d9d4dee6SDaniel J Blueman #define NUMACHIP2_APIC_ICR 0x100000 62d9d4dee6SDaniel J Blueman 63d9d4dee6SDaniel J Blueman static inline void __iomem *numachip2_lcsr_address(unsigned long offset) 64d9d4dee6SDaniel J Blueman { 65d9d4dee6SDaniel J Blueman return (void __iomem *)__va(NUMACHIP2_LCSR_BASE | 66d9d4dee6SDaniel J Blueman (offset & (NUMACHIP2_LCSR_SIZE - 1))); 67d9d4dee6SDaniel J Blueman } 68d9d4dee6SDaniel J Blueman 69d9d4dee6SDaniel J Blueman static inline u32 numachip2_read32_lcsr(unsigned long offset) 70d9d4dee6SDaniel J Blueman { 71d9d4dee6SDaniel J Blueman return readl(numachip2_lcsr_address(offset)); 72d9d4dee6SDaniel J Blueman } 73d9d4dee6SDaniel J Blueman 74d9d4dee6SDaniel J Blueman static inline u64 numachip2_read64_lcsr(unsigned long offset) 75d9d4dee6SDaniel J Blueman { 76d9d4dee6SDaniel J Blueman return readq(numachip2_lcsr_address(offset)); 77d9d4dee6SDaniel J Blueman } 78d9d4dee6SDaniel J Blueman 79d9d4dee6SDaniel J Blueman static inline void numachip2_write32_lcsr(unsigned long offset, u32 val) 80d9d4dee6SDaniel J Blueman { 81d9d4dee6SDaniel J Blueman writel(val, numachip2_lcsr_address(offset)); 82d9d4dee6SDaniel J Blueman } 83d9d4dee6SDaniel J Blueman 84d9d4dee6SDaniel J Blueman static inline void numachip2_write64_lcsr(unsigned long offset, u64 val) 85d9d4dee6SDaniel J Blueman { 86d9d4dee6SDaniel J Blueman writeq(val, numachip2_lcsr_address(offset)); 87d9d4dee6SDaniel J Blueman } 88d9d4dee6SDaniel J Blueman 8944b111b5SSteffen Persvold #endif /* _ASM_X86_NUMACHIP_NUMACHIP_CSR_H */ 90