18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/****************************************************************************/ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci/* 58c2ecf20Sopenharmony_ci * m53xxacr.h -- ColdFire version 3 core cache support 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * (C) Copyright 2010, Greg Ungerer <gerg@snapgear.com> 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/****************************************************************************/ 118c2ecf20Sopenharmony_ci#ifndef m53xxacr_h 128c2ecf20Sopenharmony_ci#define m53xxacr_h 138c2ecf20Sopenharmony_ci/****************************************************************************/ 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci/* 168c2ecf20Sopenharmony_ci * All varients of the ColdFire using version 3 cores have a similar 178c2ecf20Sopenharmony_ci * cache setup. They have a unified instruction and data cache, with 188c2ecf20Sopenharmony_ci * configurable write-through or copy-back operation. 198c2ecf20Sopenharmony_ci */ 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* 228c2ecf20Sopenharmony_ci * Define the Cache Control register flags. 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci#define CACR_EC 0x80000000 /* Enable cache */ 258c2ecf20Sopenharmony_ci#define CACR_ESB 0x20000000 /* Enable store buffer */ 268c2ecf20Sopenharmony_ci#define CACR_DPI 0x10000000 /* Disable invalidation by CPUSHL */ 278c2ecf20Sopenharmony_ci#define CACR_HLCK 0x08000000 /* Half cache lock mode */ 288c2ecf20Sopenharmony_ci#define CACR_CINVA 0x01000000 /* Invalidate cache */ 298c2ecf20Sopenharmony_ci#define CACR_DNFB 0x00000400 /* Inhibited fill buffer */ 308c2ecf20Sopenharmony_ci#define CACR_DCM_WT 0x00000000 /* Cacheable write-through */ 318c2ecf20Sopenharmony_ci#define CACR_DCM_CB 0x00000100 /* Cacheable copy-back */ 328c2ecf20Sopenharmony_ci#define CACR_DCM_PRE 0x00000200 /* Cache inhibited, precise */ 338c2ecf20Sopenharmony_ci#define CACR_DCM_IMPRE 0x00000300 /* Cache inhibited, imprecise */ 348c2ecf20Sopenharmony_ci#define CACR_WPROTECT 0x00000020 /* Write protect*/ 358c2ecf20Sopenharmony_ci#define CACR_EUSP 0x00000010 /* Eanble separate user a7 */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci/* 388c2ecf20Sopenharmony_ci * Define the Access Control register flags. 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_ci#define ACR_BASE_POS 24 /* Address Base (upper 8 bits) */ 418c2ecf20Sopenharmony_ci#define ACR_MASK_POS 16 /* Address Mask (next 8 bits) */ 428c2ecf20Sopenharmony_ci#define ACR_ENABLE 0x00008000 /* Enable this ACR */ 438c2ecf20Sopenharmony_ci#define ACR_USER 0x00000000 /* Allow only user accesses */ 448c2ecf20Sopenharmony_ci#define ACR_SUPER 0x00002000 /* Allow supervisor access only */ 458c2ecf20Sopenharmony_ci#define ACR_ANY 0x00004000 /* Allow any access type */ 468c2ecf20Sopenharmony_ci#define ACR_CM_WT 0x00000000 /* Cacheable, write-through */ 478c2ecf20Sopenharmony_ci#define ACR_CM_CB 0x00000020 /* Cacheable, copy-back */ 488c2ecf20Sopenharmony_ci#define ACR_CM_PRE 0x00000040 /* Cache inhibited, precise */ 498c2ecf20Sopenharmony_ci#define ACR_CM_IMPRE 0x00000060 /* Cache inhibited, imprecise */ 508c2ecf20Sopenharmony_ci#define ACR_WPROTECT 0x00000004 /* Write protect region */ 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * Define the cache type and arrangement (needed for pushes). 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_ci#if defined(CONFIG_M5307) 568c2ecf20Sopenharmony_ci#define CACHE_SIZE 0x2000 /* 8k of unified cache */ 578c2ecf20Sopenharmony_ci#define ICACHE_SIZE CACHE_SIZE 588c2ecf20Sopenharmony_ci#define DCACHE_SIZE CACHE_SIZE 598c2ecf20Sopenharmony_ci#elif defined(CONFIG_M53xx) 608c2ecf20Sopenharmony_ci#define CACHE_SIZE 0x4000 /* 16k of unified cache */ 618c2ecf20Sopenharmony_ci#define ICACHE_SIZE CACHE_SIZE 628c2ecf20Sopenharmony_ci#define DCACHE_SIZE CACHE_SIZE 638c2ecf20Sopenharmony_ci#endif 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#define CACHE_LINE_SIZE 16 /* 16 byte line size */ 668c2ecf20Sopenharmony_ci#define CACHE_WAYS 4 /* 4 ways - set associative */ 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* 698c2ecf20Sopenharmony_ci * Set the cache controller settings we will use. This default in the 708c2ecf20Sopenharmony_ci * CACR is cache inhibited, we use the ACR register to set cacheing 718c2ecf20Sopenharmony_ci * enabled on the regions we want (eg RAM). 728c2ecf20Sopenharmony_ci */ 738c2ecf20Sopenharmony_ci#if defined(CONFIG_CACHE_COPYBACK) 748c2ecf20Sopenharmony_ci#define CACHE_TYPE ACR_CM_CB 758c2ecf20Sopenharmony_ci#define CACHE_PUSH 768c2ecf20Sopenharmony_ci#else 778c2ecf20Sopenharmony_ci#define CACHE_TYPE ACR_CM_WT 788c2ecf20Sopenharmony_ci#endif 798c2ecf20Sopenharmony_ci 808c2ecf20Sopenharmony_ci#ifdef CONFIG_COLDFIRE_SW_A7 818c2ecf20Sopenharmony_ci#define CACHE_MODE (CACR_EC + CACR_ESB + CACR_DCM_PRE) 828c2ecf20Sopenharmony_ci#else 838c2ecf20Sopenharmony_ci#define CACHE_MODE (CACR_EC + CACR_ESB + CACR_DCM_PRE + CACR_EUSP) 848c2ecf20Sopenharmony_ci#endif 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci/* 878c2ecf20Sopenharmony_ci * Unified cache means we will never need to flush for coherency of 888c2ecf20Sopenharmony_ci * instruction fetch. We will need to flush to maintain memory/DMA 898c2ecf20Sopenharmony_ci * coherency though in all cases. And for copyback caches we will need 908c2ecf20Sopenharmony_ci * to push cached data as well. 918c2ecf20Sopenharmony_ci */ 928c2ecf20Sopenharmony_ci#define CACHE_INIT (CACHE_MODE + CACR_CINVA - CACR_EC) 938c2ecf20Sopenharmony_ci#define CACHE_INVALIDATE (CACHE_MODE + CACR_CINVA) 948c2ecf20Sopenharmony_ci#define CACHE_INVALIDATED (CACHE_MODE + CACR_CINVA) 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci#define ACR0_MODE ((CONFIG_RAMBASE & 0xff000000) + \ 978c2ecf20Sopenharmony_ci (0x000f0000) + \ 988c2ecf20Sopenharmony_ci (ACR_ENABLE + ACR_ANY + CACHE_TYPE)) 998c2ecf20Sopenharmony_ci#define ACR1_MODE 0 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/****************************************************************************/ 1028c2ecf20Sopenharmony_ci#endif /* m53xxsim_h */ 103