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 1744b111b5SSteffen Persvold #include <linux/numa.h> 1844b111b5SSteffen Persvold #include <linux/percpu.h> 1944b111b5SSteffen Persvold #include <linux/io.h> 2044b111b5SSteffen Persvold #include <linux/swab.h> 2144b111b5SSteffen Persvold #include <asm/types.h> 2244b111b5SSteffen Persvold #include <asm/processor.h> 2344b111b5SSteffen Persvold 2444b111b5SSteffen Persvold #define CSR_NODE_SHIFT 16 2544b111b5SSteffen Persvold #define CSR_NODE_BITS(p) (((unsigned long)(p)) << CSR_NODE_SHIFT) 2644b111b5SSteffen Persvold #define CSR_NODE_MASK 0x0fff /* 4K nodes */ 2744b111b5SSteffen Persvold 2844b111b5SSteffen Persvold /* 32K CSR space, b15 indicates geo/non-geo */ 2944b111b5SSteffen Persvold #define CSR_OFFSET_MASK 0x7fffUL 3044b111b5SSteffen Persvold 3144b111b5SSteffen Persvold /* Global CSR space covers all 4K possible nodes with 64K CSR space per node */ 3244b111b5SSteffen Persvold #define NUMACHIP_GCSR_BASE 0x3fff00000000ULL 3344b111b5SSteffen Persvold #define NUMACHIP_GCSR_LIM 0x3fff0fffffffULL 3444b111b5SSteffen Persvold #define NUMACHIP_GCSR_SIZE (NUMACHIP_GCSR_LIM - NUMACHIP_GCSR_BASE + 1) 3544b111b5SSteffen Persvold 3644b111b5SSteffen Persvold /* 3744b111b5SSteffen Persvold * Local CSR space starts in global CSR space with "nodeid" = 0xfff0, however 3844b111b5SSteffen Persvold * when using the direct mapping on x86_64, both start and size needs to be 3944b111b5SSteffen Persvold * aligned with PMD_SIZE which is 2M 4044b111b5SSteffen Persvold */ 4144b111b5SSteffen Persvold #define NUMACHIP_LCSR_BASE 0x3ffffe000000ULL 4244b111b5SSteffen Persvold #define NUMACHIP_LCSR_LIM 0x3fffffffffffULL 4344b111b5SSteffen Persvold #define NUMACHIP_LCSR_SIZE (NUMACHIP_LCSR_LIM - NUMACHIP_LCSR_BASE + 1) 4444b111b5SSteffen Persvold 4544b111b5SSteffen Persvold static inline void *gcsr_address(int node, unsigned long offset) 4644b111b5SSteffen Persvold { 4744b111b5SSteffen Persvold return __va(NUMACHIP_GCSR_BASE | (1UL << 15) | 4844b111b5SSteffen Persvold CSR_NODE_BITS(node & CSR_NODE_MASK) | (offset & CSR_OFFSET_MASK)); 4944b111b5SSteffen Persvold } 5044b111b5SSteffen Persvold 5144b111b5SSteffen Persvold static inline void *lcsr_address(unsigned long offset) 5244b111b5SSteffen Persvold { 5344b111b5SSteffen Persvold return __va(NUMACHIP_LCSR_BASE | (1UL << 15) | 5444b111b5SSteffen Persvold CSR_NODE_BITS(0xfff0) | (offset & CSR_OFFSET_MASK)); 5544b111b5SSteffen Persvold } 5644b111b5SSteffen Persvold 5744b111b5SSteffen Persvold static inline unsigned int read_gcsr(int node, unsigned long offset) 5844b111b5SSteffen Persvold { 5944b111b5SSteffen Persvold return swab32(readl(gcsr_address(node, offset))); 6044b111b5SSteffen Persvold } 6144b111b5SSteffen Persvold 6244b111b5SSteffen Persvold static inline void write_gcsr(int node, unsigned long offset, unsigned int val) 6344b111b5SSteffen Persvold { 6444b111b5SSteffen Persvold writel(swab32(val), gcsr_address(node, offset)); 6544b111b5SSteffen Persvold } 6644b111b5SSteffen Persvold 6744b111b5SSteffen Persvold static inline unsigned int read_lcsr(unsigned long offset) 6844b111b5SSteffen Persvold { 6944b111b5SSteffen Persvold return swab32(readl(lcsr_address(offset))); 7044b111b5SSteffen Persvold } 7144b111b5SSteffen Persvold 7244b111b5SSteffen Persvold static inline void write_lcsr(unsigned long offset, unsigned int val) 7344b111b5SSteffen Persvold { 7444b111b5SSteffen Persvold writel(swab32(val), lcsr_address(offset)); 7544b111b5SSteffen Persvold } 7644b111b5SSteffen Persvold 7744b111b5SSteffen Persvold /* ========================================================================= */ 7844b111b5SSteffen Persvold /* CSR_G0_STATE_CLEAR */ 7944b111b5SSteffen Persvold /* ========================================================================= */ 8044b111b5SSteffen Persvold 8144b111b5SSteffen Persvold #define CSR_G0_STATE_CLEAR (0x000 + (0 << 12)) 8244b111b5SSteffen Persvold union numachip_csr_g0_state_clear { 8344b111b5SSteffen Persvold unsigned int v; 8444b111b5SSteffen Persvold struct numachip_csr_g0_state_clear_s { 8544b111b5SSteffen Persvold unsigned int _state:2; 8644b111b5SSteffen Persvold unsigned int _rsvd_2_6:5; 8744b111b5SSteffen Persvold unsigned int _lost:1; 8844b111b5SSteffen Persvold unsigned int _rsvd_8_31:24; 8944b111b5SSteffen Persvold } s; 9044b111b5SSteffen Persvold }; 9144b111b5SSteffen Persvold 9244b111b5SSteffen Persvold /* ========================================================================= */ 9344b111b5SSteffen Persvold /* CSR_G0_NODE_IDS */ 9444b111b5SSteffen Persvold /* ========================================================================= */ 9544b111b5SSteffen Persvold 9644b111b5SSteffen Persvold #define CSR_G0_NODE_IDS (0x008 + (0 << 12)) 9744b111b5SSteffen Persvold union numachip_csr_g0_node_ids { 9844b111b5SSteffen Persvold unsigned int v; 9944b111b5SSteffen Persvold struct numachip_csr_g0_node_ids_s { 10044b111b5SSteffen Persvold unsigned int _initialid:16; 10144b111b5SSteffen Persvold unsigned int _nodeid:12; 10244b111b5SSteffen Persvold unsigned int _rsvd_28_31:4; 10344b111b5SSteffen Persvold } s; 10444b111b5SSteffen Persvold }; 10544b111b5SSteffen Persvold 10644b111b5SSteffen Persvold /* ========================================================================= */ 10744b111b5SSteffen Persvold /* CSR_G3_EXT_IRQ_GEN */ 10844b111b5SSteffen Persvold /* ========================================================================= */ 10944b111b5SSteffen Persvold 11044b111b5SSteffen Persvold #define CSR_G3_EXT_IRQ_GEN (0x030 + (3 << 12)) 11144b111b5SSteffen Persvold union numachip_csr_g3_ext_irq_gen { 11244b111b5SSteffen Persvold unsigned int v; 11344b111b5SSteffen Persvold struct numachip_csr_g3_ext_irq_gen_s { 11444b111b5SSteffen Persvold unsigned int _vector:8; 11544b111b5SSteffen Persvold unsigned int _msgtype:3; 11644b111b5SSteffen Persvold unsigned int _index:5; 11744b111b5SSteffen Persvold unsigned int _destination_apic_id:16; 11844b111b5SSteffen Persvold } s; 11944b111b5SSteffen Persvold }; 12044b111b5SSteffen Persvold 12144b111b5SSteffen Persvold /* ========================================================================= */ 12244b111b5SSteffen Persvold /* CSR_G3_EXT_IRQ_STATUS */ 12344b111b5SSteffen Persvold /* ========================================================================= */ 12444b111b5SSteffen Persvold 12544b111b5SSteffen Persvold #define CSR_G3_EXT_IRQ_STATUS (0x034 + (3 << 12)) 12644b111b5SSteffen Persvold union numachip_csr_g3_ext_irq_status { 12744b111b5SSteffen Persvold unsigned int v; 12844b111b5SSteffen Persvold struct numachip_csr_g3_ext_irq_status_s { 12944b111b5SSteffen Persvold unsigned int _result:32; 13044b111b5SSteffen Persvold } s; 13144b111b5SSteffen Persvold }; 13244b111b5SSteffen Persvold 13344b111b5SSteffen Persvold /* ========================================================================= */ 13444b111b5SSteffen Persvold /* CSR_G3_EXT_IRQ_DEST */ 13544b111b5SSteffen Persvold /* ========================================================================= */ 13644b111b5SSteffen Persvold 13744b111b5SSteffen Persvold #define CSR_G3_EXT_IRQ_DEST (0x038 + (3 << 12)) 13844b111b5SSteffen Persvold union numachip_csr_g3_ext_irq_dest { 13944b111b5SSteffen Persvold unsigned int v; 14044b111b5SSteffen Persvold struct numachip_csr_g3_ext_irq_dest_s { 14144b111b5SSteffen Persvold unsigned int _irq:8; 14244b111b5SSteffen Persvold unsigned int _rsvd_8_31:24; 14344b111b5SSteffen Persvold } s; 14444b111b5SSteffen Persvold }; 14544b111b5SSteffen Persvold 14644b111b5SSteffen Persvold /* ========================================================================= */ 14744b111b5SSteffen Persvold /* CSR_G3_NC_ATT_MAP_SELECT */ 14844b111b5SSteffen Persvold /* ========================================================================= */ 14944b111b5SSteffen Persvold 15044b111b5SSteffen Persvold #define CSR_G3_NC_ATT_MAP_SELECT (0x7fc + (3 << 12)) 15144b111b5SSteffen Persvold union numachip_csr_g3_nc_att_map_select { 15244b111b5SSteffen Persvold unsigned int v; 15344b111b5SSteffen Persvold struct numachip_csr_g3_nc_att_map_select_s { 15444b111b5SSteffen Persvold unsigned int _upper_address_bits:4; 15544b111b5SSteffen Persvold unsigned int _select_ram:4; 15644b111b5SSteffen Persvold unsigned int _rsvd_8_31:24; 15744b111b5SSteffen Persvold } s; 15844b111b5SSteffen Persvold }; 15944b111b5SSteffen Persvold 16044b111b5SSteffen Persvold /* ========================================================================= */ 16144b111b5SSteffen Persvold /* CSR_G3_NC_ATT_MAP_SELECT_0-255 */ 16244b111b5SSteffen Persvold /* ========================================================================= */ 16344b111b5SSteffen Persvold 16444b111b5SSteffen Persvold #define CSR_G3_NC_ATT_MAP_SELECT_0 (0x800 + (3 << 12)) 16544b111b5SSteffen Persvold 16644b111b5SSteffen Persvold #endif /* _ASM_X86_NUMACHIP_NUMACHIP_CSR_H */ 16744b111b5SSteffen Persvold 168