18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  linux/arch/arm/mm/cache-v4.S
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 1997-2002 Russell king
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci#include <linux/linkage.h>
88c2ecf20Sopenharmony_ci#include <linux/init.h>
98c2ecf20Sopenharmony_ci#include <asm/assembler.h>
108c2ecf20Sopenharmony_ci#include <asm/page.h>
118c2ecf20Sopenharmony_ci#include "proc-macros.S"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/*
148c2ecf20Sopenharmony_ci *	flush_icache_all()
158c2ecf20Sopenharmony_ci *
168c2ecf20Sopenharmony_ci *	Unconditionally clean and invalidate the entire icache.
178c2ecf20Sopenharmony_ci */
188c2ecf20Sopenharmony_ciENTRY(v4_flush_icache_all)
198c2ecf20Sopenharmony_ci	ret	lr
208c2ecf20Sopenharmony_ciENDPROC(v4_flush_icache_all)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/*
238c2ecf20Sopenharmony_ci *	flush_user_cache_all()
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci *	Invalidate all cache entries in a particular address
268c2ecf20Sopenharmony_ci *	space.
278c2ecf20Sopenharmony_ci *
288c2ecf20Sopenharmony_ci *	- mm	- mm_struct describing address space
298c2ecf20Sopenharmony_ci */
308c2ecf20Sopenharmony_ciENTRY(v4_flush_user_cache_all)
318c2ecf20Sopenharmony_ci	/* FALLTHROUGH */
328c2ecf20Sopenharmony_ci/*
338c2ecf20Sopenharmony_ci *	flush_kern_cache_all()
348c2ecf20Sopenharmony_ci *
358c2ecf20Sopenharmony_ci *	Clean and invalidate the entire cache.
368c2ecf20Sopenharmony_ci */
378c2ecf20Sopenharmony_ciENTRY(v4_flush_kern_cache_all)
388c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_CP15
398c2ecf20Sopenharmony_ci	mov	r0, #0
408c2ecf20Sopenharmony_ci	mcr	p15, 0, r0, c7, c7, 0		@ flush ID cache
418c2ecf20Sopenharmony_ci	ret	lr
428c2ecf20Sopenharmony_ci#else
438c2ecf20Sopenharmony_ci	/* FALLTHROUGH */
448c2ecf20Sopenharmony_ci#endif
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/*
478c2ecf20Sopenharmony_ci *	flush_user_cache_range(start, end, flags)
488c2ecf20Sopenharmony_ci *
498c2ecf20Sopenharmony_ci *	Invalidate a range of cache entries in the specified
508c2ecf20Sopenharmony_ci *	address space.
518c2ecf20Sopenharmony_ci *
528c2ecf20Sopenharmony_ci *	- start - start address (may not be aligned)
538c2ecf20Sopenharmony_ci *	- end	- end address (exclusive, may not be aligned)
548c2ecf20Sopenharmony_ci *	- flags	- vma_area_struct flags describing address space
558c2ecf20Sopenharmony_ci */
568c2ecf20Sopenharmony_ciENTRY(v4_flush_user_cache_range)
578c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_CP15
588c2ecf20Sopenharmony_ci	mov	ip, #0
598c2ecf20Sopenharmony_ci	mcr	p15, 0, ip, c7, c7, 0		@ flush ID cache
608c2ecf20Sopenharmony_ci	ret	lr
618c2ecf20Sopenharmony_ci#else
628c2ecf20Sopenharmony_ci	/* FALLTHROUGH */
638c2ecf20Sopenharmony_ci#endif
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/*
668c2ecf20Sopenharmony_ci *	coherent_kern_range(start, end)
678c2ecf20Sopenharmony_ci *
688c2ecf20Sopenharmony_ci *	Ensure coherency between the Icache and the Dcache in the
698c2ecf20Sopenharmony_ci *	region described by start.  If you have non-snooping
708c2ecf20Sopenharmony_ci *	Harvard caches, you need to implement this function.
718c2ecf20Sopenharmony_ci *
728c2ecf20Sopenharmony_ci *	- start  - virtual start address
738c2ecf20Sopenharmony_ci *	- end	 - virtual end address
748c2ecf20Sopenharmony_ci */
758c2ecf20Sopenharmony_ciENTRY(v4_coherent_kern_range)
768c2ecf20Sopenharmony_ci	/* FALLTHROUGH */
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci/*
798c2ecf20Sopenharmony_ci *	coherent_user_range(start, end)
808c2ecf20Sopenharmony_ci *
818c2ecf20Sopenharmony_ci *	Ensure coherency between the Icache and the Dcache in the
828c2ecf20Sopenharmony_ci *	region described by start.  If you have non-snooping
838c2ecf20Sopenharmony_ci *	Harvard caches, you need to implement this function.
848c2ecf20Sopenharmony_ci *
858c2ecf20Sopenharmony_ci *	- start  - virtual start address
868c2ecf20Sopenharmony_ci *	- end	 - virtual end address
878c2ecf20Sopenharmony_ci */
888c2ecf20Sopenharmony_ciENTRY(v4_coherent_user_range)
898c2ecf20Sopenharmony_ci	mov	r0, #0
908c2ecf20Sopenharmony_ci	ret	lr
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci/*
938c2ecf20Sopenharmony_ci *	flush_kern_dcache_area(void *addr, size_t size)
948c2ecf20Sopenharmony_ci *
958c2ecf20Sopenharmony_ci *	Ensure no D cache aliasing occurs, either with itself or
968c2ecf20Sopenharmony_ci *	the I cache
978c2ecf20Sopenharmony_ci *
988c2ecf20Sopenharmony_ci *	- addr	- kernel address
998c2ecf20Sopenharmony_ci *	- size	- region size
1008c2ecf20Sopenharmony_ci */
1018c2ecf20Sopenharmony_ciENTRY(v4_flush_kern_dcache_area)
1028c2ecf20Sopenharmony_ci	/* FALLTHROUGH */
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/*
1058c2ecf20Sopenharmony_ci *	dma_flush_range(start, end)
1068c2ecf20Sopenharmony_ci *
1078c2ecf20Sopenharmony_ci *	Clean and invalidate the specified virtual address range.
1088c2ecf20Sopenharmony_ci *
1098c2ecf20Sopenharmony_ci *	- start  - virtual start address
1108c2ecf20Sopenharmony_ci *	- end	 - virtual end address
1118c2ecf20Sopenharmony_ci */
1128c2ecf20Sopenharmony_ciENTRY(v4_dma_flush_range)
1138c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_CP15
1148c2ecf20Sopenharmony_ci	mov	r0, #0
1158c2ecf20Sopenharmony_ci	mcr	p15, 0, r0, c7, c7, 0		@ flush ID cache
1168c2ecf20Sopenharmony_ci#endif
1178c2ecf20Sopenharmony_ci	ret	lr
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci/*
1208c2ecf20Sopenharmony_ci *	dma_unmap_area(start, size, dir)
1218c2ecf20Sopenharmony_ci *	- start	- kernel virtual start address
1228c2ecf20Sopenharmony_ci *	- size	- size of region
1238c2ecf20Sopenharmony_ci *	- dir	- DMA direction
1248c2ecf20Sopenharmony_ci */
1258c2ecf20Sopenharmony_ciENTRY(v4_dma_unmap_area)
1268c2ecf20Sopenharmony_ci	teq	r2, #DMA_TO_DEVICE
1278c2ecf20Sopenharmony_ci	bne	v4_dma_flush_range
1288c2ecf20Sopenharmony_ci	/* FALLTHROUGH */
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci/*
1318c2ecf20Sopenharmony_ci *	dma_map_area(start, size, dir)
1328c2ecf20Sopenharmony_ci *	- start	- kernel virtual start address
1338c2ecf20Sopenharmony_ci *	- size	- size of region
1348c2ecf20Sopenharmony_ci *	- dir	- DMA direction
1358c2ecf20Sopenharmony_ci */
1368c2ecf20Sopenharmony_ciENTRY(v4_dma_map_area)
1378c2ecf20Sopenharmony_ci	ret	lr
1388c2ecf20Sopenharmony_ciENDPROC(v4_dma_unmap_area)
1398c2ecf20Sopenharmony_ciENDPROC(v4_dma_map_area)
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	.globl	v4_flush_kern_cache_louis
1428c2ecf20Sopenharmony_ci	.equ	v4_flush_kern_cache_louis, v4_flush_kern_cache_all
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci	__INITDATA
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	@ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
1478c2ecf20Sopenharmony_ci	define_cache_functions v4
148