18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _M68KNOMMU_CACHEFLUSH_H 38c2ecf20Sopenharmony_ci#define _M68KNOMMU_CACHEFLUSH_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* 68c2ecf20Sopenharmony_ci * (C) Copyright 2000-2010, Greg Ungerer <gerg@snapgear.com> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#include <linux/mm.h> 98c2ecf20Sopenharmony_ci#include <asm/mcfsim.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#define flush_cache_all() __flush_cache_all() 128c2ecf20Sopenharmony_ci#define flush_dcache_range(start, len) __flush_dcache_all() 138c2ecf20Sopenharmony_ci#define flush_icache_range(start, len) __flush_icache_all() 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_civoid mcf_cache_push(void); 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_cistatic inline void __clear_cache_all(void) 188c2ecf20Sopenharmony_ci{ 198c2ecf20Sopenharmony_ci#ifdef CACHE_INVALIDATE 208c2ecf20Sopenharmony_ci __asm__ __volatile__ ( 218c2ecf20Sopenharmony_ci "movec %0, %%CACR\n\t" 228c2ecf20Sopenharmony_ci "nop\n\t" 238c2ecf20Sopenharmony_ci : : "r" (CACHE_INVALIDATE) ); 248c2ecf20Sopenharmony_ci#endif 258c2ecf20Sopenharmony_ci} 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic inline void __flush_cache_all(void) 288c2ecf20Sopenharmony_ci{ 298c2ecf20Sopenharmony_ci#ifdef CACHE_PUSH 308c2ecf20Sopenharmony_ci mcf_cache_push(); 318c2ecf20Sopenharmony_ci#endif 328c2ecf20Sopenharmony_ci __clear_cache_all(); 338c2ecf20Sopenharmony_ci} 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* 368c2ecf20Sopenharmony_ci * Some ColdFire parts implement separate instruction and data caches, 378c2ecf20Sopenharmony_ci * on those we should just flush the appropriate cache. If we don't need 388c2ecf20Sopenharmony_ci * to do any specific flushing then this will be optimized away. 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_cistatic inline void __flush_icache_all(void) 418c2ecf20Sopenharmony_ci{ 428c2ecf20Sopenharmony_ci#ifdef CACHE_INVALIDATEI 438c2ecf20Sopenharmony_ci __asm__ __volatile__ ( 448c2ecf20Sopenharmony_ci "movec %0, %%CACR\n\t" 458c2ecf20Sopenharmony_ci "nop\n\t" 468c2ecf20Sopenharmony_ci : : "r" (CACHE_INVALIDATEI) ); 478c2ecf20Sopenharmony_ci#endif 488c2ecf20Sopenharmony_ci} 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cistatic inline void __flush_dcache_all(void) 518c2ecf20Sopenharmony_ci{ 528c2ecf20Sopenharmony_ci#ifdef CACHE_PUSH 538c2ecf20Sopenharmony_ci mcf_cache_push(); 548c2ecf20Sopenharmony_ci#endif 558c2ecf20Sopenharmony_ci#ifdef CACHE_INVALIDATED 568c2ecf20Sopenharmony_ci __asm__ __volatile__ ( 578c2ecf20Sopenharmony_ci "movec %0, %%CACR\n\t" 588c2ecf20Sopenharmony_ci "nop\n\t" 598c2ecf20Sopenharmony_ci : : "r" (CACHE_INVALIDATED) ); 608c2ecf20Sopenharmony_ci#else 618c2ecf20Sopenharmony_ci /* Flush the write buffer */ 628c2ecf20Sopenharmony_ci __asm__ __volatile__ ( "nop" ); 638c2ecf20Sopenharmony_ci#endif 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* 678c2ecf20Sopenharmony_ci * Push cache entries at supplied address. We want to write back any dirty 688c2ecf20Sopenharmony_ci * data and then invalidate the cache lines associated with this address. 698c2ecf20Sopenharmony_ci */ 708c2ecf20Sopenharmony_cistatic inline void cache_push(unsigned long paddr, int len) 718c2ecf20Sopenharmony_ci{ 728c2ecf20Sopenharmony_ci __flush_cache_all(); 738c2ecf20Sopenharmony_ci} 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* 768c2ecf20Sopenharmony_ci * Clear cache entries at supplied address (that is don't write back any 778c2ecf20Sopenharmony_ci * dirty data). 788c2ecf20Sopenharmony_ci */ 798c2ecf20Sopenharmony_cistatic inline void cache_clear(unsigned long paddr, int len) 808c2ecf20Sopenharmony_ci{ 818c2ecf20Sopenharmony_ci __clear_cache_all(); 828c2ecf20Sopenharmony_ci} 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci#include <asm-generic/cacheflush.h> 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci#endif /* _M68KNOMMU_CACHEFLUSH_H */ 87