18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef __MMU_H 38c2ecf20Sopenharmony_ci#define __MMU_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * Privileged Space Mapping Buffer (PMB) definitions 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#define PMB_PASCR 0xff000070 98c2ecf20Sopenharmony_ci#define PMB_IRMCR 0xff000078 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define PASCR_SE 0x80000000 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define PMB_ADDR 0xf6100000 148c2ecf20Sopenharmony_ci#define PMB_DATA 0xf7100000 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define NR_PMB_ENTRIES 16 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#define PMB_E_MASK 0x0000000f 198c2ecf20Sopenharmony_ci#define PMB_E_SHIFT 8 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define PMB_PFN_MASK 0xff000000 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define PMB_SZ_16M 0x00000000 248c2ecf20Sopenharmony_ci#define PMB_SZ_64M 0x00000010 258c2ecf20Sopenharmony_ci#define PMB_SZ_128M 0x00000080 268c2ecf20Sopenharmony_ci#define PMB_SZ_512M 0x00000090 278c2ecf20Sopenharmony_ci#define PMB_SZ_MASK PMB_SZ_512M 288c2ecf20Sopenharmony_ci#define PMB_C 0x00000008 298c2ecf20Sopenharmony_ci#define PMB_WT 0x00000001 308c2ecf20Sopenharmony_ci#define PMB_UB 0x00000200 318c2ecf20Sopenharmony_ci#define PMB_CACHE_MASK (PMB_C | PMB_WT | PMB_UB) 328c2ecf20Sopenharmony_ci#define PMB_V 0x00000100 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define PMB_NO_ENTRY (-1) 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 378c2ecf20Sopenharmony_ci#include <linux/errno.h> 388c2ecf20Sopenharmony_ci#include <linux/threads.h> 398c2ecf20Sopenharmony_ci#include <asm/page.h> 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci/* Default "unsigned long" context */ 428c2ecf20Sopenharmony_citypedef unsigned long mm_context_id_t[NR_CPUS]; 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_citypedef struct { 458c2ecf20Sopenharmony_ci#ifdef CONFIG_MMU 468c2ecf20Sopenharmony_ci mm_context_id_t id; 478c2ecf20Sopenharmony_ci void *vdso; 488c2ecf20Sopenharmony_ci#else 498c2ecf20Sopenharmony_ci unsigned long end_brk; 508c2ecf20Sopenharmony_ci#endif 518c2ecf20Sopenharmony_ci#ifdef CONFIG_BINFMT_ELF_FDPIC 528c2ecf20Sopenharmony_ci unsigned long exec_fdpic_loadmap; 538c2ecf20Sopenharmony_ci unsigned long interp_fdpic_loadmap; 548c2ecf20Sopenharmony_ci#endif 558c2ecf20Sopenharmony_ci} mm_context_t; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci#ifdef CONFIG_PMB 588c2ecf20Sopenharmony_ci/* arch/sh/mm/pmb.c */ 598c2ecf20Sopenharmony_cibool __in_29bit_mode(void); 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_civoid pmb_init(void); 628c2ecf20Sopenharmony_ciint pmb_bolt_mapping(unsigned long virt, phys_addr_t phys, 638c2ecf20Sopenharmony_ci unsigned long size, pgprot_t prot); 648c2ecf20Sopenharmony_civoid __iomem *pmb_remap_caller(phys_addr_t phys, unsigned long size, 658c2ecf20Sopenharmony_ci pgprot_t prot, void *caller); 668c2ecf20Sopenharmony_ciint pmb_unmap(void __iomem *addr); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci#else 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cistatic inline int 718c2ecf20Sopenharmony_cipmb_bolt_mapping(unsigned long virt, phys_addr_t phys, 728c2ecf20Sopenharmony_ci unsigned long size, pgprot_t prot) 738c2ecf20Sopenharmony_ci{ 748c2ecf20Sopenharmony_ci return -EINVAL; 758c2ecf20Sopenharmony_ci} 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_cistatic inline void __iomem * 788c2ecf20Sopenharmony_cipmb_remap_caller(phys_addr_t phys, unsigned long size, 798c2ecf20Sopenharmony_ci pgprot_t prot, void *caller) 808c2ecf20Sopenharmony_ci{ 818c2ecf20Sopenharmony_ci return NULL; 828c2ecf20Sopenharmony_ci} 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_cistatic inline int pmb_unmap(void __iomem *addr) 858c2ecf20Sopenharmony_ci{ 868c2ecf20Sopenharmony_ci return -EINVAL; 878c2ecf20Sopenharmony_ci} 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define pmb_init(addr) do { } while (0) 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#ifdef CONFIG_29BIT 928c2ecf20Sopenharmony_ci#define __in_29bit_mode() (1) 938c2ecf20Sopenharmony_ci#else 948c2ecf20Sopenharmony_ci#define __in_29bit_mode() (0) 958c2ecf20Sopenharmony_ci#endif 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci#endif /* CONFIG_PMB */ 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistatic inline void __iomem * 1008c2ecf20Sopenharmony_cipmb_remap(phys_addr_t phys, unsigned long size, pgprot_t prot) 1018c2ecf20Sopenharmony_ci{ 1028c2ecf20Sopenharmony_ci return pmb_remap_caller(phys, size, prot, __builtin_return_address(0)); 1038c2ecf20Sopenharmony_ci} 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ci#endif /* __MMU_H */ 108