18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * turbosparc.h: Defines specific to the TurboSparc module. 48c2ecf20Sopenharmony_ci * This is SRMMU stuff. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#ifndef _SPARC_TURBOSPARC_H 98c2ecf20Sopenharmony_ci#define _SPARC_TURBOSPARC_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <asm/asi.h> 128c2ecf20Sopenharmony_ci#include <asm/pgtsrmmu.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* Bits in the SRMMU control register for TurboSparc modules. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * ------------------------------------------------------------------- 178c2ecf20Sopenharmony_ci * |impl-vers| RSV| PMC |PE|PC| RSV |BM| RFR |IC|DC|PSO|RSV|ICS|NF|ME| 188c2ecf20Sopenharmony_ci * ------------------------------------------------------------------- 198c2ecf20Sopenharmony_ci * 31 24 23-21 20-19 18 17 16-15 14 13-10 9 8 7 6-3 2 1 0 208c2ecf20Sopenharmony_ci * 218c2ecf20Sopenharmony_ci * BM: Boot Mode -- 0 = not in boot mode, 1 = in boot mode 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * This indicates whether the TurboSparc is in boot-mode or not. 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * IC: Instruction Cache -- 0 = off, 1 = on 268c2ecf20Sopenharmony_ci * DC: Data Cache -- 0 = off, 1 = 0n 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * These bits enable the on-cpu TurboSparc split I/D caches. 298c2ecf20Sopenharmony_ci * 308c2ecf20Sopenharmony_ci * ICS: ICache Snooping -- 0 = disable, 1 = enable snooping of icache 318c2ecf20Sopenharmony_ci * NF: No Fault -- 0 = faults generate traps, 1 = faults don't trap 328c2ecf20Sopenharmony_ci * ME: MMU enable -- 0 = mmu not translating, 1 = mmu translating 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define TURBOSPARC_MMUENABLE 0x00000001 378c2ecf20Sopenharmony_ci#define TURBOSPARC_NOFAULT 0x00000002 388c2ecf20Sopenharmony_ci#define TURBOSPARC_ICSNOOP 0x00000004 398c2ecf20Sopenharmony_ci#define TURBOSPARC_PSO 0x00000080 408c2ecf20Sopenharmony_ci#define TURBOSPARC_DCENABLE 0x00000100 /* Enable data cache */ 418c2ecf20Sopenharmony_ci#define TURBOSPARC_ICENABLE 0x00000200 /* Enable instruction cache */ 428c2ecf20Sopenharmony_ci#define TURBOSPARC_BMODE 0x00004000 438c2ecf20Sopenharmony_ci#define TURBOSPARC_PARITYODD 0x00020000 /* Parity odd, if enabled */ 448c2ecf20Sopenharmony_ci#define TURBOSPARC_PCENABLE 0x00040000 /* Enable parity checking */ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci/* Bits in the CPU configuration register for TurboSparc modules. 478c2ecf20Sopenharmony_ci * 488c2ecf20Sopenharmony_ci * ------------------------------------------------------- 498c2ecf20Sopenharmony_ci * |IOClk|SNP|AXClk| RAH | WS | RSV |SBC|WT|uS2|SE|SCC| 508c2ecf20Sopenharmony_ci * ------------------------------------------------------- 518c2ecf20Sopenharmony_ci * 31 30 29-28 27-26 25-23 22-8 7-6 5 4 3 2-0 528c2ecf20Sopenharmony_ci * 538c2ecf20Sopenharmony_ci */ 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define TURBOSPARC_SCENABLE 0x00000008 /* Secondary cache enable */ 568c2ecf20Sopenharmony_ci#define TURBOSPARC_uS2 0x00000010 /* Swift compatibility mode */ 578c2ecf20Sopenharmony_ci#define TURBOSPARC_WTENABLE 0x00000020 /* Write thru for dcache */ 588c2ecf20Sopenharmony_ci#define TURBOSPARC_SNENABLE 0x40000000 /* DVMA snoop enable */ 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* Bits [13:5] select one of 512 instruction cache tags */ 638c2ecf20Sopenharmony_cistatic inline void turbosparc_inv_insn_tag(unsigned long addr) 648c2ecf20Sopenharmony_ci{ 658c2ecf20Sopenharmony_ci __asm__ __volatile__("sta %%g0, [%0] %1\n\t" 668c2ecf20Sopenharmony_ci : /* no outputs */ 678c2ecf20Sopenharmony_ci : "r" (addr), "i" (ASI_M_TXTC_TAG) 688c2ecf20Sopenharmony_ci : "memory"); 698c2ecf20Sopenharmony_ci} 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci/* Bits [13:5] select one of 512 data cache tags */ 728c2ecf20Sopenharmony_cistatic inline void turbosparc_inv_data_tag(unsigned long addr) 738c2ecf20Sopenharmony_ci{ 748c2ecf20Sopenharmony_ci __asm__ __volatile__("sta %%g0, [%0] %1\n\t" 758c2ecf20Sopenharmony_ci : /* no outputs */ 768c2ecf20Sopenharmony_ci : "r" (addr), "i" (ASI_M_DATAC_TAG) 778c2ecf20Sopenharmony_ci : "memory"); 788c2ecf20Sopenharmony_ci} 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_cistatic inline void turbosparc_flush_icache(void) 818c2ecf20Sopenharmony_ci{ 828c2ecf20Sopenharmony_ci unsigned long addr; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci for (addr = 0; addr < 0x4000; addr += 0x20) 858c2ecf20Sopenharmony_ci turbosparc_inv_insn_tag(addr); 868c2ecf20Sopenharmony_ci} 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistatic inline void turbosparc_flush_dcache(void) 898c2ecf20Sopenharmony_ci{ 908c2ecf20Sopenharmony_ci unsigned long addr; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci for (addr = 0; addr < 0x4000; addr += 0x20) 938c2ecf20Sopenharmony_ci turbosparc_inv_data_tag(addr); 948c2ecf20Sopenharmony_ci} 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_cistatic inline void turbosparc_idflash_clear(void) 978c2ecf20Sopenharmony_ci{ 988c2ecf20Sopenharmony_ci unsigned long addr; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci for (addr = 0; addr < 0x4000; addr += 0x20) { 1018c2ecf20Sopenharmony_ci turbosparc_inv_insn_tag(addr); 1028c2ecf20Sopenharmony_ci turbosparc_inv_data_tag(addr); 1038c2ecf20Sopenharmony_ci } 1048c2ecf20Sopenharmony_ci} 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_cistatic inline void turbosparc_set_ccreg(unsigned long regval) 1078c2ecf20Sopenharmony_ci{ 1088c2ecf20Sopenharmony_ci __asm__ __volatile__("sta %0, [%1] %2\n\t" 1098c2ecf20Sopenharmony_ci : /* no outputs */ 1108c2ecf20Sopenharmony_ci : "r" (regval), "r" (0x600), "i" (ASI_M_MMUREGS) 1118c2ecf20Sopenharmony_ci : "memory"); 1128c2ecf20Sopenharmony_ci} 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_cistatic inline unsigned long turbosparc_get_ccreg(void) 1158c2ecf20Sopenharmony_ci{ 1168c2ecf20Sopenharmony_ci unsigned long regval; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci __asm__ __volatile__("lda [%1] %2, %0\n\t" 1198c2ecf20Sopenharmony_ci : "=r" (regval) 1208c2ecf20Sopenharmony_ci : "r" (0x600), "i" (ASI_M_MMUREGS)); 1218c2ecf20Sopenharmony_ci return regval; 1228c2ecf20Sopenharmony_ci} 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci#endif /* !(_SPARC_TURBOSPARC_H) */ 127