162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _SPARC64_UPA_H 362306a36Sopenharmony_ci#define _SPARC64_UPA_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <asm/asi.h> 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci/* UPA level registers and defines. */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* UPA Config Register */ 1062306a36Sopenharmony_ci#define UPA_CONFIG_RESV 0xffffffffc0000000 /* Reserved. */ 1162306a36Sopenharmony_ci#define UPA_CONFIG_PCON 0x000000003fc00000 /* Depth of various sys queues. */ 1262306a36Sopenharmony_ci#define UPA_CONFIG_MID 0x00000000003e0000 /* Module ID. */ 1362306a36Sopenharmony_ci#define UPA_CONFIG_PCAP 0x000000000001ffff /* Port Capabilities. */ 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* UPA Port ID Register */ 1662306a36Sopenharmony_ci#define UPA_PORTID_FNP 0xff00000000000000 /* Hardcoded to 0xfc on ultra. */ 1762306a36Sopenharmony_ci#define UPA_PORTID_RESV 0x00fffff800000000 /* Reserved. */ 1862306a36Sopenharmony_ci#define UPA_PORTID_ECCVALID 0x0000000400000000 /* Zero if mod can generate ECC */ 1962306a36Sopenharmony_ci#define UPA_PORTID_ONEREAD 0x0000000200000000 /* Set if mod generates P_RASB */ 2062306a36Sopenharmony_ci#define UPA_PORTID_PINTRDQ 0x0000000180000000 /* # outstanding P_INT_REQ's */ 2162306a36Sopenharmony_ci#define UPA_PORTID_PREQDQ 0x000000007e000000 /* slave-wr's to mod supported */ 2262306a36Sopenharmony_ci#define UPA_PORTID_PREQRD 0x0000000001e00000 /* # incoming P_REQ's supported */ 2362306a36Sopenharmony_ci#define UPA_PORTID_UPACAP 0x00000000001f0000 /* UPA capabilities of mod */ 2462306a36Sopenharmony_ci#define UPA_PORTID_ID 0x000000000000ffff /* Module Identification bits */ 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* UPA I/O space accessors */ 2762306a36Sopenharmony_ci#if defined(__KERNEL__) && !defined(__ASSEMBLY__) 2862306a36Sopenharmony_cistatic inline unsigned char _upa_readb(unsigned long addr) 2962306a36Sopenharmony_ci{ 3062306a36Sopenharmony_ci unsigned char ret; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci __asm__ __volatile__("lduba\t[%1] %2, %0\t/* upa_readb */" 3362306a36Sopenharmony_ci : "=r" (ret) 3462306a36Sopenharmony_ci : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci return ret; 3762306a36Sopenharmony_ci} 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_cistatic inline unsigned short _upa_readw(unsigned long addr) 4062306a36Sopenharmony_ci{ 4162306a36Sopenharmony_ci unsigned short ret; 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci __asm__ __volatile__("lduha\t[%1] %2, %0\t/* upa_readw */" 4462306a36Sopenharmony_ci : "=r" (ret) 4562306a36Sopenharmony_ci : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci return ret; 4862306a36Sopenharmony_ci} 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_cistatic inline unsigned int _upa_readl(unsigned long addr) 5162306a36Sopenharmony_ci{ 5262306a36Sopenharmony_ci unsigned int ret; 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci __asm__ __volatile__("lduwa\t[%1] %2, %0\t/* upa_readl */" 5562306a36Sopenharmony_ci : "=r" (ret) 5662306a36Sopenharmony_ci : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci return ret; 5962306a36Sopenharmony_ci} 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_cistatic inline unsigned long _upa_readq(unsigned long addr) 6262306a36Sopenharmony_ci{ 6362306a36Sopenharmony_ci unsigned long ret; 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci __asm__ __volatile__("ldxa\t[%1] %2, %0\t/* upa_readq */" 6662306a36Sopenharmony_ci : "=r" (ret) 6762306a36Sopenharmony_ci : "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci return ret; 7062306a36Sopenharmony_ci} 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_cistatic inline void _upa_writeb(unsigned char b, unsigned long addr) 7362306a36Sopenharmony_ci{ 7462306a36Sopenharmony_ci __asm__ __volatile__("stba\t%0, [%1] %2\t/* upa_writeb */" 7562306a36Sopenharmony_ci : /* no outputs */ 7662306a36Sopenharmony_ci : "r" (b), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 7762306a36Sopenharmony_ci} 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_cistatic inline void _upa_writew(unsigned short w, unsigned long addr) 8062306a36Sopenharmony_ci{ 8162306a36Sopenharmony_ci __asm__ __volatile__("stha\t%0, [%1] %2\t/* upa_writew */" 8262306a36Sopenharmony_ci : /* no outputs */ 8362306a36Sopenharmony_ci : "r" (w), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 8462306a36Sopenharmony_ci} 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_cistatic inline void _upa_writel(unsigned int l, unsigned long addr) 8762306a36Sopenharmony_ci{ 8862306a36Sopenharmony_ci __asm__ __volatile__("stwa\t%0, [%1] %2\t/* upa_writel */" 8962306a36Sopenharmony_ci : /* no outputs */ 9062306a36Sopenharmony_ci : "r" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 9162306a36Sopenharmony_ci} 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cistatic inline void _upa_writeq(unsigned long q, unsigned long addr) 9462306a36Sopenharmony_ci{ 9562306a36Sopenharmony_ci __asm__ __volatile__("stxa\t%0, [%1] %2\t/* upa_writeq */" 9662306a36Sopenharmony_ci : /* no outputs */ 9762306a36Sopenharmony_ci : "r" (q), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E)); 9862306a36Sopenharmony_ci} 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#define upa_readb(__addr) (_upa_readb((unsigned long)(__addr))) 10162306a36Sopenharmony_ci#define upa_readw(__addr) (_upa_readw((unsigned long)(__addr))) 10262306a36Sopenharmony_ci#define upa_readl(__addr) (_upa_readl((unsigned long)(__addr))) 10362306a36Sopenharmony_ci#define upa_readq(__addr) (_upa_readq((unsigned long)(__addr))) 10462306a36Sopenharmony_ci#define upa_writeb(__b, __addr) (_upa_writeb((__b), (unsigned long)(__addr))) 10562306a36Sopenharmony_ci#define upa_writew(__w, __addr) (_upa_writew((__w), (unsigned long)(__addr))) 10662306a36Sopenharmony_ci#define upa_writel(__l, __addr) (_upa_writel((__l), (unsigned long)(__addr))) 10762306a36Sopenharmony_ci#define upa_writeq(__q, __addr) (_upa_writeq((__q), (unsigned long)(__addr))) 10862306a36Sopenharmony_ci#endif /* __KERNEL__ && !__ASSEMBLY__ */ 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci#endif /* !(_SPARC64_UPA_H) */ 111