18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* swift.h: Specific definitions for the _broken_ Swift SRMMU 38c2ecf20Sopenharmony_ci * MMU module. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _SPARC_SWIFT_H 98c2ecf20Sopenharmony_ci#define _SPARC_SWIFT_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* Swift is so brain damaged, here is the mmu control register. */ 128c2ecf20Sopenharmony_ci#define SWIFT_ST 0x00800000 /* SW tablewalk enable */ 138c2ecf20Sopenharmony_ci#define SWIFT_WP 0x00400000 /* Watchpoint enable */ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* Branch folding (buggy, disable on production systems!) */ 168c2ecf20Sopenharmony_ci#define SWIFT_BF 0x00200000 178c2ecf20Sopenharmony_ci#define SWIFT_PMC 0x00180000 /* Page mode control */ 188c2ecf20Sopenharmony_ci#define SWIFT_PE 0x00040000 /* Parity enable */ 198c2ecf20Sopenharmony_ci#define SWIFT_PC 0x00020000 /* Parity control */ 208c2ecf20Sopenharmony_ci#define SWIFT_AP 0x00010000 /* Graphics page mode control (TCX/SX) */ 218c2ecf20Sopenharmony_ci#define SWIFT_AC 0x00008000 /* Alternate Cacheability (see viking.h) */ 228c2ecf20Sopenharmony_ci#define SWIFT_BM 0x00004000 /* Boot mode */ 238c2ecf20Sopenharmony_ci#define SWIFT_RC 0x00003c00 /* DRAM refresh control */ 248c2ecf20Sopenharmony_ci#define SWIFT_IE 0x00000200 /* Instruction cache enable */ 258c2ecf20Sopenharmony_ci#define SWIFT_DE 0x00000100 /* Data cache enable */ 268c2ecf20Sopenharmony_ci#define SWIFT_SA 0x00000080 /* Store Allocate */ 278c2ecf20Sopenharmony_ci#define SWIFT_NF 0x00000002 /* No fault mode */ 288c2ecf20Sopenharmony_ci#define SWIFT_EN 0x00000001 /* MMU enable */ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* Bits [13:5] select one of 512 instruction cache tags */ 318c2ecf20Sopenharmony_cistatic inline void swift_inv_insn_tag(unsigned long addr) 328c2ecf20Sopenharmony_ci{ 338c2ecf20Sopenharmony_ci __asm__ __volatile__("sta %%g0, [%0] %1\n\t" 348c2ecf20Sopenharmony_ci : /* no outputs */ 358c2ecf20Sopenharmony_ci : "r" (addr), "i" (ASI_M_TXTC_TAG) 368c2ecf20Sopenharmony_ci : "memory"); 378c2ecf20Sopenharmony_ci} 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* Bits [12:4] select one of 512 data cache tags */ 408c2ecf20Sopenharmony_cistatic inline void swift_inv_data_tag(unsigned long addr) 418c2ecf20Sopenharmony_ci{ 428c2ecf20Sopenharmony_ci __asm__ __volatile__("sta %%g0, [%0] %1\n\t" 438c2ecf20Sopenharmony_ci : /* no outputs */ 448c2ecf20Sopenharmony_ci : "r" (addr), "i" (ASI_M_DATAC_TAG) 458c2ecf20Sopenharmony_ci : "memory"); 468c2ecf20Sopenharmony_ci} 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_cistatic inline void swift_flush_dcache(void) 498c2ecf20Sopenharmony_ci{ 508c2ecf20Sopenharmony_ci unsigned long addr; 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci for (addr = 0; addr < 0x2000; addr += 0x10) 538c2ecf20Sopenharmony_ci swift_inv_data_tag(addr); 548c2ecf20Sopenharmony_ci} 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistatic inline void swift_flush_icache(void) 578c2ecf20Sopenharmony_ci{ 588c2ecf20Sopenharmony_ci unsigned long addr; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci for (addr = 0; addr < 0x4000; addr += 0x20) 618c2ecf20Sopenharmony_ci swift_inv_insn_tag(addr); 628c2ecf20Sopenharmony_ci} 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistatic inline void swift_idflash_clear(void) 658c2ecf20Sopenharmony_ci{ 668c2ecf20Sopenharmony_ci unsigned long addr; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci for (addr = 0; addr < 0x2000; addr += 0x10) { 698c2ecf20Sopenharmony_ci swift_inv_insn_tag(addr<<1); 708c2ecf20Sopenharmony_ci swift_inv_data_tag(addr); 718c2ecf20Sopenharmony_ci } 728c2ecf20Sopenharmony_ci} 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* Swift is so broken, it isn't even safe to use the following. */ 758c2ecf20Sopenharmony_cistatic inline void swift_flush_page(unsigned long page) 768c2ecf20Sopenharmony_ci{ 778c2ecf20Sopenharmony_ci __asm__ __volatile__("sta %%g0, [%0] %1\n\t" 788c2ecf20Sopenharmony_ci : /* no outputs */ 798c2ecf20Sopenharmony_ci : "r" (page), "i" (ASI_M_FLUSH_PAGE) 808c2ecf20Sopenharmony_ci : "memory"); 818c2ecf20Sopenharmony_ci} 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_cistatic inline void swift_flush_segment(unsigned long addr) 848c2ecf20Sopenharmony_ci{ 858c2ecf20Sopenharmony_ci __asm__ __volatile__("sta %%g0, [%0] %1\n\t" 868c2ecf20Sopenharmony_ci : /* no outputs */ 878c2ecf20Sopenharmony_ci : "r" (addr), "i" (ASI_M_FLUSH_SEG) 888c2ecf20Sopenharmony_ci : "memory"); 898c2ecf20Sopenharmony_ci} 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_cistatic inline void swift_flush_region(unsigned long addr) 928c2ecf20Sopenharmony_ci{ 938c2ecf20Sopenharmony_ci __asm__ __volatile__("sta %%g0, [%0] %1\n\t" 948c2ecf20Sopenharmony_ci : /* no outputs */ 958c2ecf20Sopenharmony_ci : "r" (addr), "i" (ASI_M_FLUSH_REGION) 968c2ecf20Sopenharmony_ci : "memory"); 978c2ecf20Sopenharmony_ci} 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistatic inline void swift_flush_context(void) 1008c2ecf20Sopenharmony_ci{ 1018c2ecf20Sopenharmony_ci __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t" 1028c2ecf20Sopenharmony_ci : /* no outputs */ 1038c2ecf20Sopenharmony_ci : "i" (ASI_M_FLUSH_CTX) 1048c2ecf20Sopenharmony_ci : "memory"); 1058c2ecf20Sopenharmony_ci} 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#endif /* !(_SPARC_SWIFT_H) */ 108