18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci// Copyright (C) 2005-2017 Andes Technology Corporation
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#ifndef _ASMNDS32_TLBFLUSH_H
58c2ecf20Sopenharmony_ci#define _ASMNDS32_TLBFLUSH_H
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
88c2ecf20Sopenharmony_ci#include <linux/mm.h>
98c2ecf20Sopenharmony_ci#include <nds32_intrinsic.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistatic inline void local_flush_tlb_all(void)
128c2ecf20Sopenharmony_ci{
138c2ecf20Sopenharmony_ci	__nds32__tlbop_flua();
148c2ecf20Sopenharmony_ci	__nds32__isb();
158c2ecf20Sopenharmony_ci}
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistatic inline void local_flush_tlb_mm(struct mm_struct *mm)
188c2ecf20Sopenharmony_ci{
198c2ecf20Sopenharmony_ci	__nds32__tlbop_flua();
208c2ecf20Sopenharmony_ci	__nds32__isb();
218c2ecf20Sopenharmony_ci}
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_cistatic inline void local_flush_tlb_kernel_range(unsigned long start,
248c2ecf20Sopenharmony_ci						unsigned long end)
258c2ecf20Sopenharmony_ci{
268c2ecf20Sopenharmony_ci	while (start < end) {
278c2ecf20Sopenharmony_ci		__nds32__tlbop_inv(start);
288c2ecf20Sopenharmony_ci		__nds32__isb();
298c2ecf20Sopenharmony_ci		start += PAGE_SIZE;
308c2ecf20Sopenharmony_ci	}
318c2ecf20Sopenharmony_ci}
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_civoid local_flush_tlb_range(struct vm_area_struct *vma,
348c2ecf20Sopenharmony_ci			   unsigned long start, unsigned long end);
358c2ecf20Sopenharmony_civoid local_flush_tlb_page(struct vm_area_struct *vma, unsigned long addr);
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#define flush_tlb_all		local_flush_tlb_all
388c2ecf20Sopenharmony_ci#define flush_tlb_mm		local_flush_tlb_mm
398c2ecf20Sopenharmony_ci#define flush_tlb_range		local_flush_tlb_range
408c2ecf20Sopenharmony_ci#define flush_tlb_page		local_flush_tlb_page
418c2ecf20Sopenharmony_ci#define flush_tlb_kernel_range	local_flush_tlb_kernel_range
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_civoid update_mmu_cache(struct vm_area_struct *vma,
448c2ecf20Sopenharmony_ci		      unsigned long address, pte_t * pte);
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#endif
47