18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * obio.h: Some useful locations in 0xFXXXXXXXX PA obio space on sun4d. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1997 Jakub Jelinek <jj@sunsite.mff.cuni.cz> 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _SPARC_OBIO_H 98c2ecf20Sopenharmony_ci#define _SPARC_OBIO_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <asm/asi.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* This weird monster likes to use the very upper parts of 148c2ecf20Sopenharmony_ci 36bit PA for these things :) */ 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* CSR space (for each XDBUS) 178c2ecf20Sopenharmony_ci * ------------------------------------------------------------------------ 188c2ecf20Sopenharmony_ci * | 0xFE | DEVID | | XDBUS ID | | 198c2ecf20Sopenharmony_ci * ------------------------------------------------------------------------ 208c2ecf20Sopenharmony_ci * 35 28 27 20 19 10 9 8 7 0 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define CSR_BASE_ADDR 0xe0000000 248c2ecf20Sopenharmony_ci#define CSR_CPU_SHIFT (32 - 4 - 5) 258c2ecf20Sopenharmony_ci#define CSR_XDBUS_SHIFT 8 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#define CSR_BASE(cpu) (((CSR_BASE_ADDR >> CSR_CPU_SHIFT) + cpu) << CSR_CPU_SHIFT) 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* ECSR space (not for each XDBUS) 308c2ecf20Sopenharmony_ci * ------------------------------------------------------------------------ 318c2ecf20Sopenharmony_ci * | 0xF | DEVID[7:1] | | 328c2ecf20Sopenharmony_ci * ------------------------------------------------------------------------ 338c2ecf20Sopenharmony_ci * 35 32 31 25 24 0 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define ECSR_BASE_ADDR 0x00000000 378c2ecf20Sopenharmony_ci#define ECSR_CPU_SHIFT (32 - 5) 388c2ecf20Sopenharmony_ci#define ECSR_DEV_SHIFT (32 - 8) 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#define ECSR_BASE(cpu) ((cpu) << ECSR_CPU_SHIFT) 418c2ecf20Sopenharmony_ci#define ECSR_DEV_BASE(devid) ((devid) << ECSR_DEV_SHIFT) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* Bus Watcher */ 448c2ecf20Sopenharmony_ci#define BW_LOCAL_BASE 0xfff00000 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define BW_CID 0x00000000 478c2ecf20Sopenharmony_ci#define BW_DBUS_CTRL 0x00000008 488c2ecf20Sopenharmony_ci#define BW_DBUS_DATA 0x00000010 498c2ecf20Sopenharmony_ci#define BW_CTRL 0x00001000 508c2ecf20Sopenharmony_ci#define BW_INTR_TABLE 0x00001040 518c2ecf20Sopenharmony_ci#define BW_INTR_TABLE_CLEAR 0x00001080 528c2ecf20Sopenharmony_ci#define BW_PRESCALER 0x000010c0 538c2ecf20Sopenharmony_ci#define BW_PTIMER_LIMIT 0x00002000 548c2ecf20Sopenharmony_ci#define BW_PTIMER_COUNTER2 0x00002004 558c2ecf20Sopenharmony_ci#define BW_PTIMER_NDLIMIT 0x00002008 568c2ecf20Sopenharmony_ci#define BW_PTIMER_CTRL 0x0000200c 578c2ecf20Sopenharmony_ci#define BW_PTIMER_COUNTER 0x00002010 588c2ecf20Sopenharmony_ci#define BW_TIMER_LIMIT 0x00003000 598c2ecf20Sopenharmony_ci#define BW_TIMER_COUNTER2 0x00003004 608c2ecf20Sopenharmony_ci#define BW_TIMER_NDLIMIT 0x00003008 618c2ecf20Sopenharmony_ci#define BW_TIMER_CTRL 0x0000300c 628c2ecf20Sopenharmony_ci#define BW_TIMER_COUNTER 0x00003010 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci/* BW Control */ 658c2ecf20Sopenharmony_ci#define BW_CTRL_USER_TIMER 0x00000004 /* Is User Timer Free run enabled */ 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci/* Boot Bus */ 688c2ecf20Sopenharmony_ci#define BB_LOCAL_BASE 0xf0000000 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci#define BB_STAT1 0x00100000 718c2ecf20Sopenharmony_ci#define BB_STAT2 0x00120000 728c2ecf20Sopenharmony_ci#define BB_STAT3 0x00140000 738c2ecf20Sopenharmony_ci#define BB_LEDS 0x002e0000 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* Bits in BB_STAT2 */ 768c2ecf20Sopenharmony_ci#define BB_STAT2_AC_INTR 0x04 /* Aiee! 5ms and power is gone... */ 778c2ecf20Sopenharmony_ci#define BB_STAT2_TMP_INTR 0x10 /* My Penguins are burning. Are you able to smell it? */ 788c2ecf20Sopenharmony_ci#define BB_STAT2_FAN_INTR 0x20 /* My fan refuses to work */ 798c2ecf20Sopenharmony_ci#define BB_STAT2_PWR_INTR 0x40 /* On SC2000, one of the two ACs died. Ok, we go on... */ 808c2ecf20Sopenharmony_ci#define BB_STAT2_MASK (BB_STAT2_AC_INTR|BB_STAT2_TMP_INTR|BB_STAT2_FAN_INTR|BB_STAT2_PWR_INTR) 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci/* Cache Controller */ 838c2ecf20Sopenharmony_ci#define CC_BASE 0x1F00000 848c2ecf20Sopenharmony_ci#define CC_DATSTREAM 0x1F00000 /* Data stream register */ 858c2ecf20Sopenharmony_ci#define CC_DATSIZE 0x1F0003F /* Size */ 868c2ecf20Sopenharmony_ci#define CC_SRCSTREAM 0x1F00100 /* Source stream register */ 878c2ecf20Sopenharmony_ci#define CC_DESSTREAM 0x1F00200 /* Destination stream register */ 888c2ecf20Sopenharmony_ci#define CC_RMCOUNT 0x1F00300 /* Count of references and misses */ 898c2ecf20Sopenharmony_ci#define CC_IPEN 0x1F00406 /* Pending Interrupts */ 908c2ecf20Sopenharmony_ci#define CC_IMSK 0x1F00506 /* Interrupt Mask */ 918c2ecf20Sopenharmony_ci#define CC_ICLR 0x1F00606 /* Clear pending Interrupts */ 928c2ecf20Sopenharmony_ci#define CC_IGEN 0x1F00704 /* Generate Interrupt register */ 938c2ecf20Sopenharmony_ci#define CC_STEST 0x1F00804 /* Internal self-test */ 948c2ecf20Sopenharmony_ci#define CC_CREG 0x1F00A04 /* Control register */ 958c2ecf20Sopenharmony_ci#define CC_SREG 0x1F00B00 /* Status register */ 968c2ecf20Sopenharmony_ci#define CC_RREG 0x1F00C04 /* Reset register */ 978c2ecf20Sopenharmony_ci#define CC_EREG 0x1F00E00 /* Error code register */ 988c2ecf20Sopenharmony_ci#define CC_CID 0x1F00F04 /* Component ID */ 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistatic inline int bw_get_intr_mask(int sbus_level) 1038c2ecf20Sopenharmony_ci{ 1048c2ecf20Sopenharmony_ci int mask; 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci __asm__ __volatile__ ("lduha [%1] %2, %0" : 1078c2ecf20Sopenharmony_ci "=r" (mask) : 1088c2ecf20Sopenharmony_ci "r" (BW_LOCAL_BASE + BW_INTR_TABLE + (sbus_level << 3)), 1098c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 1108c2ecf20Sopenharmony_ci return mask; 1118c2ecf20Sopenharmony_ci} 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_cistatic inline void bw_clear_intr_mask(int sbus_level, int mask) 1148c2ecf20Sopenharmony_ci{ 1158c2ecf20Sopenharmony_ci __asm__ __volatile__ ("stha %0, [%1] %2" : : 1168c2ecf20Sopenharmony_ci "r" (mask), 1178c2ecf20Sopenharmony_ci "r" (BW_LOCAL_BASE + BW_INTR_TABLE_CLEAR + (sbus_level << 3)), 1188c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 1198c2ecf20Sopenharmony_ci} 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_cistatic inline unsigned int bw_get_prof_limit(int cpu) 1228c2ecf20Sopenharmony_ci{ 1238c2ecf20Sopenharmony_ci unsigned int limit; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci __asm__ __volatile__ ("lda [%1] %2, %0" : 1268c2ecf20Sopenharmony_ci "=r" (limit) : 1278c2ecf20Sopenharmony_ci "r" (CSR_BASE(cpu) + BW_PTIMER_LIMIT), 1288c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 1298c2ecf20Sopenharmony_ci return limit; 1308c2ecf20Sopenharmony_ci} 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cistatic inline void bw_set_prof_limit(int cpu, unsigned int limit) 1338c2ecf20Sopenharmony_ci{ 1348c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sta %0, [%1] %2" : : 1358c2ecf20Sopenharmony_ci "r" (limit), 1368c2ecf20Sopenharmony_ci "r" (CSR_BASE(cpu) + BW_PTIMER_LIMIT), 1378c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 1388c2ecf20Sopenharmony_ci} 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_cistatic inline unsigned int bw_get_ctrl(int cpu) 1418c2ecf20Sopenharmony_ci{ 1428c2ecf20Sopenharmony_ci unsigned int ctrl; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci __asm__ __volatile__ ("lda [%1] %2, %0" : 1458c2ecf20Sopenharmony_ci "=r" (ctrl) : 1468c2ecf20Sopenharmony_ci "r" (CSR_BASE(cpu) + BW_CTRL), 1478c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 1488c2ecf20Sopenharmony_ci return ctrl; 1498c2ecf20Sopenharmony_ci} 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_cistatic inline void bw_set_ctrl(int cpu, unsigned int ctrl) 1528c2ecf20Sopenharmony_ci{ 1538c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sta %0, [%1] %2" : : 1548c2ecf20Sopenharmony_ci "r" (ctrl), 1558c2ecf20Sopenharmony_ci "r" (CSR_BASE(cpu) + BW_CTRL), 1568c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 1578c2ecf20Sopenharmony_ci} 1588c2ecf20Sopenharmony_ci 1598c2ecf20Sopenharmony_cistatic inline unsigned int cc_get_ipen(void) 1608c2ecf20Sopenharmony_ci{ 1618c2ecf20Sopenharmony_ci unsigned int pending; 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci __asm__ __volatile__ ("lduha [%1] %2, %0" : 1648c2ecf20Sopenharmony_ci "=r" (pending) : 1658c2ecf20Sopenharmony_ci "r" (CC_IPEN), 1668c2ecf20Sopenharmony_ci "i" (ASI_M_MXCC)); 1678c2ecf20Sopenharmony_ci return pending; 1688c2ecf20Sopenharmony_ci} 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_cistatic inline void cc_set_iclr(unsigned int clear) 1718c2ecf20Sopenharmony_ci{ 1728c2ecf20Sopenharmony_ci __asm__ __volatile__ ("stha %0, [%1] %2" : : 1738c2ecf20Sopenharmony_ci "r" (clear), 1748c2ecf20Sopenharmony_ci "r" (CC_ICLR), 1758c2ecf20Sopenharmony_ci "i" (ASI_M_MXCC)); 1768c2ecf20Sopenharmony_ci} 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_cistatic inline unsigned int cc_get_imsk(void) 1798c2ecf20Sopenharmony_ci{ 1808c2ecf20Sopenharmony_ci unsigned int mask; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci __asm__ __volatile__ ("lduha [%1] %2, %0" : 1838c2ecf20Sopenharmony_ci "=r" (mask) : 1848c2ecf20Sopenharmony_ci "r" (CC_IMSK), 1858c2ecf20Sopenharmony_ci "i" (ASI_M_MXCC)); 1868c2ecf20Sopenharmony_ci return mask; 1878c2ecf20Sopenharmony_ci} 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_cistatic inline void cc_set_imsk(unsigned int mask) 1908c2ecf20Sopenharmony_ci{ 1918c2ecf20Sopenharmony_ci __asm__ __volatile__ ("stha %0, [%1] %2" : : 1928c2ecf20Sopenharmony_ci "r" (mask), 1938c2ecf20Sopenharmony_ci "r" (CC_IMSK), 1948c2ecf20Sopenharmony_ci "i" (ASI_M_MXCC)); 1958c2ecf20Sopenharmony_ci} 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_cistatic inline unsigned int cc_get_imsk_other(int cpuid) 1988c2ecf20Sopenharmony_ci{ 1998c2ecf20Sopenharmony_ci unsigned int mask; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci __asm__ __volatile__ ("lduha [%1] %2, %0" : 2028c2ecf20Sopenharmony_ci "=r" (mask) : 2038c2ecf20Sopenharmony_ci "r" (ECSR_BASE(cpuid) | CC_IMSK), 2048c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 2058c2ecf20Sopenharmony_ci return mask; 2068c2ecf20Sopenharmony_ci} 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_cistatic inline void cc_set_imsk_other(int cpuid, unsigned int mask) 2098c2ecf20Sopenharmony_ci{ 2108c2ecf20Sopenharmony_ci __asm__ __volatile__ ("stha %0, [%1] %2" : : 2118c2ecf20Sopenharmony_ci "r" (mask), 2128c2ecf20Sopenharmony_ci "r" (ECSR_BASE(cpuid) | CC_IMSK), 2138c2ecf20Sopenharmony_ci "i" (ASI_M_CTL)); 2148c2ecf20Sopenharmony_ci} 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_cistatic inline void cc_set_igen(unsigned int gen) 2178c2ecf20Sopenharmony_ci{ 2188c2ecf20Sopenharmony_ci __asm__ __volatile__ ("sta %0, [%1] %2" : : 2198c2ecf20Sopenharmony_ci "r" (gen), 2208c2ecf20Sopenharmony_ci "r" (CC_IGEN), 2218c2ecf20Sopenharmony_ci "i" (ASI_M_MXCC)); 2228c2ecf20Sopenharmony_ci} 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci#endif /* !(_SPARC_OBIO_H) */ 227