18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ASM_POWERPC_MMU_44X_H_ 38c2ecf20Sopenharmony_ci#define _ASM_POWERPC_MMU_44X_H_ 48c2ecf20Sopenharmony_ci/* 58c2ecf20Sopenharmony_ci * PPC440 support 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <asm/asm-const.h> 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#define PPC44x_MMUCR_TID 0x000000ff 118c2ecf20Sopenharmony_ci#define PPC44x_MMUCR_STS 0x00010000 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define PPC44x_TLB_PAGEID 0 148c2ecf20Sopenharmony_ci#define PPC44x_TLB_XLAT 1 158c2ecf20Sopenharmony_ci#define PPC44x_TLB_ATTRIB 2 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/* Page identification fields */ 188c2ecf20Sopenharmony_ci#define PPC44x_TLB_EPN_MASK 0xfffffc00 /* Effective Page Number */ 198c2ecf20Sopenharmony_ci#define PPC44x_TLB_VALID 0x00000200 /* Valid flag */ 208c2ecf20Sopenharmony_ci#define PPC44x_TLB_TS 0x00000100 /* Translation address space */ 218c2ecf20Sopenharmony_ci#define PPC44x_TLB_1K 0x00000000 /* Page sizes */ 228c2ecf20Sopenharmony_ci#define PPC44x_TLB_4K 0x00000010 238c2ecf20Sopenharmony_ci#define PPC44x_TLB_16K 0x00000020 248c2ecf20Sopenharmony_ci#define PPC44x_TLB_64K 0x00000030 258c2ecf20Sopenharmony_ci#define PPC44x_TLB_256K 0x00000040 268c2ecf20Sopenharmony_ci#define PPC44x_TLB_1M 0x00000050 278c2ecf20Sopenharmony_ci#define PPC44x_TLB_16M 0x00000070 288c2ecf20Sopenharmony_ci#define PPC44x_TLB_256M 0x00000090 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci/* Translation fields */ 318c2ecf20Sopenharmony_ci#define PPC44x_TLB_RPN_MASK 0xfffffc00 /* Real Page Number */ 328c2ecf20Sopenharmony_ci#define PPC44x_TLB_ERPN_MASK 0x0000000f 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* Storage attribute and access control fields */ 358c2ecf20Sopenharmony_ci#define PPC44x_TLB_ATTR_MASK 0x0000ff80 368c2ecf20Sopenharmony_ci#define PPC44x_TLB_U0 0x00008000 /* User 0 */ 378c2ecf20Sopenharmony_ci#define PPC44x_TLB_U1 0x00004000 /* User 1 */ 388c2ecf20Sopenharmony_ci#define PPC44x_TLB_U2 0x00002000 /* User 2 */ 398c2ecf20Sopenharmony_ci#define PPC44x_TLB_U3 0x00001000 /* User 3 */ 408c2ecf20Sopenharmony_ci#define PPC44x_TLB_W 0x00000800 /* Caching is write-through */ 418c2ecf20Sopenharmony_ci#define PPC44x_TLB_I 0x00000400 /* Caching is inhibited */ 428c2ecf20Sopenharmony_ci#define PPC44x_TLB_M 0x00000200 /* Memory is coherent */ 438c2ecf20Sopenharmony_ci#define PPC44x_TLB_G 0x00000100 /* Memory is guarded */ 448c2ecf20Sopenharmony_ci#define PPC44x_TLB_E 0x00000080 /* Memory is little endian */ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define PPC44x_TLB_PERM_MASK 0x0000003f 478c2ecf20Sopenharmony_ci#define PPC44x_TLB_UX 0x00000020 /* User execution */ 488c2ecf20Sopenharmony_ci#define PPC44x_TLB_UW 0x00000010 /* User write */ 498c2ecf20Sopenharmony_ci#define PPC44x_TLB_UR 0x00000008 /* User read */ 508c2ecf20Sopenharmony_ci#define PPC44x_TLB_SX 0x00000004 /* Super execution */ 518c2ecf20Sopenharmony_ci#define PPC44x_TLB_SW 0x00000002 /* Super write */ 528c2ecf20Sopenharmony_ci#define PPC44x_TLB_SR 0x00000001 /* Super read */ 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* Number of TLB entries */ 558c2ecf20Sopenharmony_ci#define PPC44x_TLB_SIZE 64 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci/* 47x bits */ 588c2ecf20Sopenharmony_ci#define PPC47x_MMUCR_TID 0x0000ffff 598c2ecf20Sopenharmony_ci#define PPC47x_MMUCR_STS 0x00010000 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* Page identification fields */ 628c2ecf20Sopenharmony_ci#define PPC47x_TLB0_EPN_MASK 0xfffff000 /* Effective Page Number */ 638c2ecf20Sopenharmony_ci#define PPC47x_TLB0_VALID 0x00000800 /* Valid flag */ 648c2ecf20Sopenharmony_ci#define PPC47x_TLB0_TS 0x00000400 /* Translation address space */ 658c2ecf20Sopenharmony_ci#define PPC47x_TLB0_4K 0x00000000 668c2ecf20Sopenharmony_ci#define PPC47x_TLB0_16K 0x00000010 678c2ecf20Sopenharmony_ci#define PPC47x_TLB0_64K 0x00000030 688c2ecf20Sopenharmony_ci#define PPC47x_TLB0_1M 0x00000070 698c2ecf20Sopenharmony_ci#define PPC47x_TLB0_16M 0x000000f0 708c2ecf20Sopenharmony_ci#define PPC47x_TLB0_256M 0x000001f0 718c2ecf20Sopenharmony_ci#define PPC47x_TLB0_1G 0x000003f0 728c2ecf20Sopenharmony_ci#define PPC47x_TLB0_BOLTED_R 0x00000008 /* tlbre only */ 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* Translation fields */ 758c2ecf20Sopenharmony_ci#define PPC47x_TLB1_RPN_MASK 0xfffff000 /* Real Page Number */ 768c2ecf20Sopenharmony_ci#define PPC47x_TLB1_ERPN_MASK 0x000003ff 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci/* Storage attribute and access control fields */ 798c2ecf20Sopenharmony_ci#define PPC47x_TLB2_ATTR_MASK 0x0003ff80 808c2ecf20Sopenharmony_ci#define PPC47x_TLB2_IL1I 0x00020000 /* Memory is guarded */ 818c2ecf20Sopenharmony_ci#define PPC47x_TLB2_IL1D 0x00010000 /* Memory is guarded */ 828c2ecf20Sopenharmony_ci#define PPC47x_TLB2_U0 0x00008000 /* User 0 */ 838c2ecf20Sopenharmony_ci#define PPC47x_TLB2_U1 0x00004000 /* User 1 */ 848c2ecf20Sopenharmony_ci#define PPC47x_TLB2_U2 0x00002000 /* User 2 */ 858c2ecf20Sopenharmony_ci#define PPC47x_TLB2_U3 0x00001000 /* User 3 */ 868c2ecf20Sopenharmony_ci#define PPC47x_TLB2_W 0x00000800 /* Caching is write-through */ 878c2ecf20Sopenharmony_ci#define PPC47x_TLB2_I 0x00000400 /* Caching is inhibited */ 888c2ecf20Sopenharmony_ci#define PPC47x_TLB2_M 0x00000200 /* Memory is coherent */ 898c2ecf20Sopenharmony_ci#define PPC47x_TLB2_G 0x00000100 /* Memory is guarded */ 908c2ecf20Sopenharmony_ci#define PPC47x_TLB2_E 0x00000080 /* Memory is little endian */ 918c2ecf20Sopenharmony_ci#define PPC47x_TLB2_PERM_MASK 0x0000003f 928c2ecf20Sopenharmony_ci#define PPC47x_TLB2_UX 0x00000020 /* User execution */ 938c2ecf20Sopenharmony_ci#define PPC47x_TLB2_UW 0x00000010 /* User write */ 948c2ecf20Sopenharmony_ci#define PPC47x_TLB2_UR 0x00000008 /* User read */ 958c2ecf20Sopenharmony_ci#define PPC47x_TLB2_SX 0x00000004 /* Super execution */ 968c2ecf20Sopenharmony_ci#define PPC47x_TLB2_SW 0x00000002 /* Super write */ 978c2ecf20Sopenharmony_ci#define PPC47x_TLB2_SR 0x00000001 /* Super read */ 988c2ecf20Sopenharmony_ci#define PPC47x_TLB2_U_RWX (PPC47x_TLB2_UX|PPC47x_TLB2_UW|PPC47x_TLB2_UR) 998c2ecf20Sopenharmony_ci#define PPC47x_TLB2_S_RWX (PPC47x_TLB2_SX|PPC47x_TLB2_SW|PPC47x_TLB2_SR) 1008c2ecf20Sopenharmony_ci#define PPC47x_TLB2_S_RW (PPC47x_TLB2_SW | PPC47x_TLB2_SR) 1018c2ecf20Sopenharmony_ci#define PPC47x_TLB2_IMG (PPC47x_TLB2_I | PPC47x_TLB2_M | PPC47x_TLB2_G) 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciextern unsigned int tlb_44x_hwater; 1068c2ecf20Sopenharmony_ciextern unsigned int tlb_44x_index; 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_citypedef struct { 1098c2ecf20Sopenharmony_ci unsigned int id; 1108c2ecf20Sopenharmony_ci unsigned int active; 1118c2ecf20Sopenharmony_ci unsigned long vdso_base; 1128c2ecf20Sopenharmony_ci} mm_context_t; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci/* patch sites */ 1158c2ecf20Sopenharmony_ciextern s32 patch__tlb_44x_hwater_D, patch__tlb_44x_hwater_I; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci#endif /* !__ASSEMBLY__ */ 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci#ifndef CONFIG_PPC_EARLY_DEBUG_44x 1208c2ecf20Sopenharmony_ci#define PPC44x_EARLY_TLBS 1 1218c2ecf20Sopenharmony_ci#else 1228c2ecf20Sopenharmony_ci#define PPC44x_EARLY_TLBS 2 1238c2ecf20Sopenharmony_ci#define PPC44x_EARLY_DEBUG_VIRTADDR (ASM_CONST(0xf0000000) \ 1248c2ecf20Sopenharmony_ci | (ASM_CONST(CONFIG_PPC_EARLY_DEBUG_44x_PHYSLOW) & 0xffff)) 1258c2ecf20Sopenharmony_ci#endif 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci/* Size of the TLBs used for pinning in lowmem */ 1288c2ecf20Sopenharmony_ci#define PPC_PIN_SIZE (1 << 28) /* 256M */ 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci#if defined(CONFIG_PPC_4K_PAGES) 1318c2ecf20Sopenharmony_ci#define PPC44x_TLBE_SIZE PPC44x_TLB_4K 1328c2ecf20Sopenharmony_ci#define PPC47x_TLBE_SIZE PPC47x_TLB0_4K 1338c2ecf20Sopenharmony_ci#define mmu_virtual_psize MMU_PAGE_4K 1348c2ecf20Sopenharmony_ci#elif defined(CONFIG_PPC_16K_PAGES) 1358c2ecf20Sopenharmony_ci#define PPC44x_TLBE_SIZE PPC44x_TLB_16K 1368c2ecf20Sopenharmony_ci#define PPC47x_TLBE_SIZE PPC47x_TLB0_16K 1378c2ecf20Sopenharmony_ci#define mmu_virtual_psize MMU_PAGE_16K 1388c2ecf20Sopenharmony_ci#elif defined(CONFIG_PPC_64K_PAGES) 1398c2ecf20Sopenharmony_ci#define PPC44x_TLBE_SIZE PPC44x_TLB_64K 1408c2ecf20Sopenharmony_ci#define PPC47x_TLBE_SIZE PPC47x_TLB0_64K 1418c2ecf20Sopenharmony_ci#define mmu_virtual_psize MMU_PAGE_64K 1428c2ecf20Sopenharmony_ci#elif defined(CONFIG_PPC_256K_PAGES) 1438c2ecf20Sopenharmony_ci#define PPC44x_TLBE_SIZE PPC44x_TLB_256K 1448c2ecf20Sopenharmony_ci#define mmu_virtual_psize MMU_PAGE_256K 1458c2ecf20Sopenharmony_ci#else 1468c2ecf20Sopenharmony_ci#error "Unsupported PAGE_SIZE" 1478c2ecf20Sopenharmony_ci#endif 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci#define mmu_linear_psize MMU_PAGE_256M 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci#define PPC44x_PGD_OFF_SHIFT (32 - PGDIR_SHIFT + PGD_T_LOG2) 1528c2ecf20Sopenharmony_ci#define PPC44x_PGD_OFF_MASK_BIT (PGDIR_SHIFT - PGD_T_LOG2) 1538c2ecf20Sopenharmony_ci#define PPC44x_PTE_ADD_SHIFT (32 - PGDIR_SHIFT + PTE_SHIFT + PTE_T_LOG2) 1548c2ecf20Sopenharmony_ci#define PPC44x_PTE_ADD_MASK_BIT (32 - PTE_T_LOG2 - PTE_SHIFT) 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci#endif /* _ASM_POWERPC_MMU_44X_H_ */ 157