18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 38c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 48c2ecf20Sopenharmony_ci * for more details. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Numascale NumaConnect-Specific Header file 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Copyright (C) 2011 Numascale AS. All rights reserved. 98c2ecf20Sopenharmony_ci * 108c2ecf20Sopenharmony_ci * Send feedback to <support@numascale.com> 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci */ 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#ifndef _ASM_X86_NUMACHIP_NUMACHIP_CSR_H 158c2ecf20Sopenharmony_ci#define _ASM_X86_NUMACHIP_NUMACHIP_CSR_H 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#include <linux/smp.h> 188c2ecf20Sopenharmony_ci#include <linux/io.h> 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define CSR_NODE_SHIFT 16 218c2ecf20Sopenharmony_ci#define CSR_NODE_BITS(p) (((unsigned long)(p)) << CSR_NODE_SHIFT) 228c2ecf20Sopenharmony_ci#define CSR_NODE_MASK 0x0fff /* 4K nodes */ 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* 32K CSR space, b15 indicates geo/non-geo */ 258c2ecf20Sopenharmony_ci#define CSR_OFFSET_MASK 0x7fffUL 268c2ecf20Sopenharmony_ci#define CSR_G0_NODE_IDS (0x008 + (0 << 12)) 278c2ecf20Sopenharmony_ci#define CSR_G3_EXT_IRQ_GEN (0x030 + (3 << 12)) 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* 308c2ecf20Sopenharmony_ci * Local CSR space starts in global CSR space with "nodeid" = 0xfff0, however 318c2ecf20Sopenharmony_ci * when using the direct mapping on x86_64, both start and size needs to be 328c2ecf20Sopenharmony_ci * aligned with PMD_SIZE which is 2M 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_ci#define NUMACHIP_LCSR_BASE 0x3ffffe000000ULL 358c2ecf20Sopenharmony_ci#define NUMACHIP_LCSR_LIM 0x3fffffffffffULL 368c2ecf20Sopenharmony_ci#define NUMACHIP_LCSR_SIZE (NUMACHIP_LCSR_LIM - NUMACHIP_LCSR_BASE + 1) 378c2ecf20Sopenharmony_ci#define NUMACHIP_LAPIC_BITS 8 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistatic inline void *lcsr_address(unsigned long offset) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci return __va(NUMACHIP_LCSR_BASE | (1UL << 15) | 428c2ecf20Sopenharmony_ci CSR_NODE_BITS(0xfff0) | (offset & CSR_OFFSET_MASK)); 438c2ecf20Sopenharmony_ci} 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistatic inline unsigned int read_lcsr(unsigned long offset) 468c2ecf20Sopenharmony_ci{ 478c2ecf20Sopenharmony_ci return swab32(readl(lcsr_address(offset))); 488c2ecf20Sopenharmony_ci} 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistatic inline void write_lcsr(unsigned long offset, unsigned int val) 518c2ecf20Sopenharmony_ci{ 528c2ecf20Sopenharmony_ci writel(swab32(val), lcsr_address(offset)); 538c2ecf20Sopenharmony_ci} 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci/* 568c2ecf20Sopenharmony_ci * On NumaChip2, local CSR space is 16MB and starts at fixed offset below 4G 578c2ecf20Sopenharmony_ci */ 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci#define NUMACHIP2_LCSR_BASE 0xf0000000UL 608c2ecf20Sopenharmony_ci#define NUMACHIP2_LCSR_SIZE 0x1000000UL 618c2ecf20Sopenharmony_ci#define NUMACHIP2_APIC_ICR 0x100000 628c2ecf20Sopenharmony_ci#define NUMACHIP2_TIMER_DEADLINE 0x200000 638c2ecf20Sopenharmony_ci#define NUMACHIP2_TIMER_INT 0x200008 648c2ecf20Sopenharmony_ci#define NUMACHIP2_TIMER_NOW 0x200018 658c2ecf20Sopenharmony_ci#define NUMACHIP2_TIMER_RESET 0x200020 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistatic inline void __iomem *numachip2_lcsr_address(unsigned long offset) 688c2ecf20Sopenharmony_ci{ 698c2ecf20Sopenharmony_ci return (void __iomem *)__va(NUMACHIP2_LCSR_BASE | 708c2ecf20Sopenharmony_ci (offset & (NUMACHIP2_LCSR_SIZE - 1))); 718c2ecf20Sopenharmony_ci} 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cistatic inline u32 numachip2_read32_lcsr(unsigned long offset) 748c2ecf20Sopenharmony_ci{ 758c2ecf20Sopenharmony_ci return readl(numachip2_lcsr_address(offset)); 768c2ecf20Sopenharmony_ci} 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_cistatic inline u64 numachip2_read64_lcsr(unsigned long offset) 798c2ecf20Sopenharmony_ci{ 808c2ecf20Sopenharmony_ci return readq(numachip2_lcsr_address(offset)); 818c2ecf20Sopenharmony_ci} 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistatic inline void numachip2_write32_lcsr(unsigned long offset, u32 val) 848c2ecf20Sopenharmony_ci{ 858c2ecf20Sopenharmony_ci writel(val, numachip2_lcsr_address(offset)); 868c2ecf20Sopenharmony_ci} 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistatic inline void numachip2_write64_lcsr(unsigned long offset, u64 val) 898c2ecf20Sopenharmony_ci{ 908c2ecf20Sopenharmony_ci writeq(val, numachip2_lcsr_address(offset)); 918c2ecf20Sopenharmony_ci} 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistatic inline unsigned int numachip2_timer(void) 948c2ecf20Sopenharmony_ci{ 958c2ecf20Sopenharmony_ci return (smp_processor_id() % 48) << 6; 968c2ecf20Sopenharmony_ci} 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#endif /* _ASM_X86_NUMACHIP_NUMACHIP_CSR_H */ 99