18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _SPARC64_UPA_H 38c2ecf20Sopenharmony_ci#define _SPARC64_UPA_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <asm/asi.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/* UPA level registers and defines. */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci/* UPA Config Register */ 108c2ecf20Sopenharmony_ci#define UPA_CONFIG_RESV 0xffffffffc0000000 /* Reserved. */ 118c2ecf20Sopenharmony_ci#define UPA_CONFIG_PCON 0x000000003fc00000 /* Depth of various sys queues. */ 128c2ecf20Sopenharmony_ci#define UPA_CONFIG_MID 0x00000000003e0000 /* Module ID. */ 138c2ecf20Sopenharmony_ci#define UPA_CONFIG_PCAP 0x000000000001ffff /* Port Capabilities. */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* UPA Port ID Register */ 168c2ecf20Sopenharmony_ci#define UPA_PORTID_FNP 0xff00000000000000 /* Hardcoded to 0xfc on ultra. */ 178c2ecf20Sopenharmony_ci#define UPA_PORTID_RESV 0x00fffff800000000 /* Reserved. */ 188c2ecf20Sopenharmony_ci#define UPA_PORTID_ECCVALID 0x0000000400000000 /* Zero if mod can generate ECC */ 198c2ecf20Sopenharmony_ci#define UPA_PORTID_ONEREAD 0x0000000200000000 /* Set if mod generates P_RASB */ 208c2ecf20Sopenharmony_ci#define UPA_PORTID_PINTRDQ 0x0000000180000000 /* # outstanding P_INT_REQ's */ 218c2ecf20Sopenharmony_ci#define UPA_PORTID_PREQDQ 0x000000007e000000 /* slave-wr's to mod supported */ 228c2ecf20Sopenharmony_ci#define UPA_PORTID_PREQRD 0x0000000001e00000 /* # incoming P_REQ's supported */ 238c2ecf20Sopenharmony_ci#define UPA_PORTID_UPACAP 0x00000000001f0000 /* UPA capabilities of mod */ 248c2ecf20Sopenharmony_ci#define UPA_PORTID_ID 0x000000000000ffff /* Module Identification bits */ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* UPA I/O space accessors */ 278c2ecf20Sopenharmony_ci#if defined(__KERNEL__) && !defined(__ASSEMBLY__) 288c2ecf20Sopenharmony_cistatic inline unsigned char _upa_readb(unsigned long addr) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci unsigned char ret; 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci __asm__ __volatile__("lduba\t[%1] %2, %0\t/* upa_readb */" 338c2ecf20Sopenharmony_ci : "=r" (ret) 348c2ecf20Sopenharmony_ci : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci return ret; 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistatic inline unsigned short _upa_readw(unsigned long addr) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci unsigned short ret; 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci __asm__ __volatile__("lduha\t[%1] %2, %0\t/* upa_readw */" 448c2ecf20Sopenharmony_ci : "=r" (ret) 458c2ecf20Sopenharmony_ci : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci return ret; 488c2ecf20Sopenharmony_ci} 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistatic inline unsigned int _upa_readl(unsigned long addr) 518c2ecf20Sopenharmony_ci{ 528c2ecf20Sopenharmony_ci unsigned int ret; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* upa_readl */" 558c2ecf20Sopenharmony_ci : "=r" (ret) 568c2ecf20Sopenharmony_ci : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci return ret; 598c2ecf20Sopenharmony_ci} 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_cistatic inline unsigned long _upa_readq(unsigned long addr) 628c2ecf20Sopenharmony_ci{ 638c2ecf20Sopenharmony_ci unsigned long ret; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci __asm__ __volatile__("ldxa\t[%1] %2, %0\t/* upa_readq */" 668c2ecf20Sopenharmony_ci : "=r" (ret) 678c2ecf20Sopenharmony_ci : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci return ret; 708c2ecf20Sopenharmony_ci} 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_cistatic inline void _upa_writeb(unsigned char b, unsigned long addr) 738c2ecf20Sopenharmony_ci{ 748c2ecf20Sopenharmony_ci __asm__ __volatile__("stba\t%0, [%1] %2\t/* upa_writeb */" 758c2ecf20Sopenharmony_ci : /* no outputs */ 768c2ecf20Sopenharmony_ci : "r" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistatic inline void _upa_writew(unsigned short w, unsigned long addr) 808c2ecf20Sopenharmony_ci{ 818c2ecf20Sopenharmony_ci __asm__ __volatile__("stha\t%0, [%1] %2\t/* upa_writew */" 828c2ecf20Sopenharmony_ci : /* no outputs */ 838c2ecf20Sopenharmony_ci : "r" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 848c2ecf20Sopenharmony_ci} 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_cistatic inline void _upa_writel(unsigned int l, unsigned long addr) 878c2ecf20Sopenharmony_ci{ 888c2ecf20Sopenharmony_ci __asm__ __volatile__("stwa\t%0, [%1] %2\t/* upa_writel */" 898c2ecf20Sopenharmony_ci : /* no outputs */ 908c2ecf20Sopenharmony_ci : "r" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 918c2ecf20Sopenharmony_ci} 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_cistatic inline void _upa_writeq(unsigned long q, unsigned long addr) 948c2ecf20Sopenharmony_ci{ 958c2ecf20Sopenharmony_ci __asm__ __volatile__("stxa\t%0, [%1] %2\t/* upa_writeq */" 968c2ecf20Sopenharmony_ci : /* no outputs */ 978c2ecf20Sopenharmony_ci : "r" (q), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 988c2ecf20Sopenharmony_ci} 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#define upa_readb(__addr) (_upa_readb((unsigned long)(__addr))) 1018c2ecf20Sopenharmony_ci#define upa_readw(__addr) (_upa_readw((unsigned long)(__addr))) 1028c2ecf20Sopenharmony_ci#define upa_readl(__addr) (_upa_readl((unsigned long)(__addr))) 1038c2ecf20Sopenharmony_ci#define upa_readq(__addr) (_upa_readq((unsigned long)(__addr))) 1048c2ecf20Sopenharmony_ci#define upa_writeb(__b, __addr) (_upa_writeb((__b), (unsigned long)(__addr))) 1058c2ecf20Sopenharmony_ci#define upa_writew(__w, __addr) (_upa_writew((__w), (unsigned long)(__addr))) 1068c2ecf20Sopenharmony_ci#define upa_writel(__l, __addr) (_upa_writel((__l), (unsigned long)(__addr))) 1078c2ecf20Sopenharmony_ci#define upa_writeq(__q, __addr) (_upa_writeq((__q), (unsigned long)(__addr))) 1088c2ecf20Sopenharmony_ci#endif /* __KERNEL__ && !__ASSEMBLY__ */ 1098c2ecf20Sopenharmony_ci 1108c2ecf20Sopenharmony_ci#endif /* !(_SPARC64_UPA_H) */ 111