18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * mcfmmu.h -- definitions for the ColdFire v4e MMU 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * (C) Copyright 2011, Greg Ungerer <gerg@uclinux.org> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 78c2ecf20Sopenharmony_ci * License. See the file COPYING in the main directory of this archive 88c2ecf20Sopenharmony_ci * for more details. 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef MCFMMU_H 128c2ecf20Sopenharmony_ci#define MCFMMU_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* 158c2ecf20Sopenharmony_ci * The MMU support registers are mapped into the address space using 168c2ecf20Sopenharmony_ci * the processor MMUBASE register. We used a fixed address for mapping, 178c2ecf20Sopenharmony_ci * there doesn't seem any need to make this configurable yet. 188c2ecf20Sopenharmony_ci */ 198c2ecf20Sopenharmony_ci#define MMUBASE 0xfe000000 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* 228c2ecf20Sopenharmony_ci * The support registers of the MMU. Names are the sames as those 238c2ecf20Sopenharmony_ci * used in the Freescale v4e documentation. 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci#define MMUCR (MMUBASE + 0x00) /* Control register */ 268c2ecf20Sopenharmony_ci#define MMUOR (MMUBASE + 0x04) /* Operation register */ 278c2ecf20Sopenharmony_ci#define MMUSR (MMUBASE + 0x08) /* Status register */ 288c2ecf20Sopenharmony_ci#define MMUAR (MMUBASE + 0x10) /* TLB Address register */ 298c2ecf20Sopenharmony_ci#define MMUTR (MMUBASE + 0x14) /* TLB Tag register */ 308c2ecf20Sopenharmony_ci#define MMUDR (MMUBASE + 0x18) /* TLB Data register */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* 338c2ecf20Sopenharmony_ci * MMU Control register bit flags 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_ci#define MMUCR_EN 0x00000001 /* Virtual mode enable */ 368c2ecf20Sopenharmony_ci#define MMUCR_ASM 0x00000002 /* Address space mode */ 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* 398c2ecf20Sopenharmony_ci * MMU Operation register. 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_ci#define MMUOR_UAA 0x00000001 /* Update allocation address */ 428c2ecf20Sopenharmony_ci#define MMUOR_ACC 0x00000002 /* TLB access */ 438c2ecf20Sopenharmony_ci#define MMUOR_RD 0x00000004 /* TLB access read */ 448c2ecf20Sopenharmony_ci#define MMUOR_WR 0x00000000 /* TLB access write */ 458c2ecf20Sopenharmony_ci#define MMUOR_ADR 0x00000008 /* TLB address select */ 468c2ecf20Sopenharmony_ci#define MMUOR_ITLB 0x00000010 /* ITLB operation */ 478c2ecf20Sopenharmony_ci#define MMUOR_CAS 0x00000020 /* Clear non-locked ASID TLBs */ 488c2ecf20Sopenharmony_ci#define MMUOR_CNL 0x00000040 /* Clear non-locked TLBs */ 498c2ecf20Sopenharmony_ci#define MMUOR_CA 0x00000080 /* Clear all TLBs */ 508c2ecf20Sopenharmony_ci#define MMUOR_STLB 0x00000100 /* Search TLBs */ 518c2ecf20Sopenharmony_ci#define MMUOR_AAN 16 /* TLB allocation address */ 528c2ecf20Sopenharmony_ci#define MMUOR_AAMASK 0xffff0000 /* AA mask */ 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* 558c2ecf20Sopenharmony_ci * MMU Status register. 568c2ecf20Sopenharmony_ci */ 578c2ecf20Sopenharmony_ci#define MMUSR_HIT 0x00000002 /* Search TLB hit */ 588c2ecf20Sopenharmony_ci#define MMUSR_WF 0x00000008 /* Write access fault */ 598c2ecf20Sopenharmony_ci#define MMUSR_RF 0x00000010 /* Read access fault */ 608c2ecf20Sopenharmony_ci#define MMUSR_SPF 0x00000020 /* Supervisor protect fault */ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* 638c2ecf20Sopenharmony_ci * MMU Read/Write Tag register. 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_ci#define MMUTR_V 0x00000001 /* Valid */ 668c2ecf20Sopenharmony_ci#define MMUTR_SG 0x00000002 /* Shared global */ 678c2ecf20Sopenharmony_ci#define MMUTR_IDN 2 /* Address Space ID */ 688c2ecf20Sopenharmony_ci#define MMUTR_IDMASK 0x000003fc /* ASID mask */ 698c2ecf20Sopenharmony_ci#define MMUTR_VAN 10 /* Virtual Address */ 708c2ecf20Sopenharmony_ci#define MMUTR_VAMASK 0xfffffc00 /* VA mask */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci/* 738c2ecf20Sopenharmony_ci * MMU Read/Write Data register. 748c2ecf20Sopenharmony_ci */ 758c2ecf20Sopenharmony_ci#define MMUDR_LK 0x00000002 /* Lock entry */ 768c2ecf20Sopenharmony_ci#define MMUDR_X 0x00000004 /* Execute access enable */ 778c2ecf20Sopenharmony_ci#define MMUDR_W 0x00000008 /* Write access enable */ 788c2ecf20Sopenharmony_ci#define MMUDR_R 0x00000010 /* Read access enable */ 798c2ecf20Sopenharmony_ci#define MMUDR_SP 0x00000020 /* Supervisor access enable */ 808c2ecf20Sopenharmony_ci#define MMUDR_CM_CWT 0x00000000 /* Cachable write thru */ 818c2ecf20Sopenharmony_ci#define MMUDR_CM_CCB 0x00000040 /* Cachable copy back */ 828c2ecf20Sopenharmony_ci#define MMUDR_CM_NCP 0x00000080 /* Non-cachable precise */ 838c2ecf20Sopenharmony_ci#define MMUDR_CM_NCI 0x000000c0 /* Non-cachable imprecise */ 848c2ecf20Sopenharmony_ci#define MMUDR_SZ_1MB 0x00000000 /* 1MB page size */ 858c2ecf20Sopenharmony_ci#define MMUDR_SZ_4KB 0x00000100 /* 4kB page size */ 868c2ecf20Sopenharmony_ci#define MMUDR_SZ_8KB 0x00000200 /* 8kB page size */ 878c2ecf20Sopenharmony_ci#define MMUDR_SZ_1KB 0x00000300 /* 1kB page size */ 888c2ecf20Sopenharmony_ci#define MMUDR_PAN 10 /* Physical address */ 898c2ecf20Sopenharmony_ci#define MMUDR_PAMASK 0xfffffc00 /* PA mask */ 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* 948c2ecf20Sopenharmony_ci * Simple access functions for the MMU registers. Nothing fancy 958c2ecf20Sopenharmony_ci * currently required, just simple 32bit access. 968c2ecf20Sopenharmony_ci */ 978c2ecf20Sopenharmony_cistatic inline u32 mmu_read(u32 a) 988c2ecf20Sopenharmony_ci{ 998c2ecf20Sopenharmony_ci return *((volatile u32 *) a); 1008c2ecf20Sopenharmony_ci} 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistatic inline void mmu_write(u32 a, u32 v) 1038c2ecf20Sopenharmony_ci{ 1048c2ecf20Sopenharmony_ci *((volatile u32 *) a) = v; 1058c2ecf20Sopenharmony_ci __asm__ __volatile__ ("nop"); 1068c2ecf20Sopenharmony_ci} 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_civoid cf_bootmem_alloc(void); 1098c2ecf20Sopenharmony_civoid cf_mmu_context_init(void); 1108c2ecf20Sopenharmony_ciint cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word); 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci#endif 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci#endif /* MCFMMU_H */ 115