summaryrefslogtreecommitdiffstats
path: root/arch/riscv/include/asm/cache.h
blob: c787f890017e88698311be2fe156ed271d9b517b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2015 Regents of the University of California
 */

#ifndef _ASM_RISCV_CACHE_H
#define _ASM_RISCV_CACHE_H

#include <asm/vendorid_list.h>

static inline void thead_local_flush_icache_all(void)
{
	/*
	 * According [1] "13.3 Example of cache settings"
	 * [1]: https://github.com/T-head-Semi/openc906/blob/main/ \
	 *	doc/openc906%20datasheet.pd
	 */
	__asm__ volatile (".long 0x0100000b" ::: "memory"); /* th.icache.iall */
	__asm__ volatile (".long 0x01b0000b" ::: "memory"); /* th.sync.is */
}

static inline void local_flush_icache_all(void)
{
#ifdef CONFIG_HAS_CACHE
	switch(riscv_vendor_id()) {
	case THEAD_VENDOR_ID:
		thead_local_flush_icache_all();
		break;
	default:
		__asm__ volatile ("fence.i" ::: "memory");
	}
#endif
}

#define sync_caches_for_execution sync_caches_for_execution
void sync_caches_for_execution(void);

#include <asm-generic/cache.h>

#endif /* _ASM_RISCV_CACHEFLUSH_H */