summaryrefslogtreecommitdiff
path: root/arch/riscv/include/asm/clint.h
blob: 6eaa2eedd69418d0baf4efad5516bf9e96d044c0 (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
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _ASM_RISCV_CLINT_H
#define _ASM_RISCV_CLINT_H 1

#include <linux/io.h>
#include <linux/smp.h>

#ifdef CONFIG_RISCV_M_MODE
extern u32 __iomem *clint_ipi_base;

void clint_init_boot_cpu(void);

static inline void clint_send_ipi_single(unsigned long hartid)
{
	writel(1, clint_ipi_base + hartid);
}

static inline void clint_send_ipi_mask(const struct cpumask *hartid_mask)
{
	int hartid;

	for_each_cpu(hartid, hartid_mask)
		clint_send_ipi_single(hartid);
}

static inline void clint_clear_ipi(unsigned long hartid)
{
	writel(0, clint_ipi_base + hartid);
}
#else /* CONFIG_RISCV_M_MODE */
#define clint_init_boot_cpu()	do { } while (0)

/* stubs to for code is only reachable under IS_ENABLED(CONFIG_RISCV_M_MODE): */
void clint_send_ipi_single(unsigned long hartid);
void clint_send_ipi_mask(const struct cpumask *hartid_mask);
void clint_clear_ipi(unsigned long hartid);
#endif /* CONFIG_RISCV_M_MODE */

#endif /* _ASM_RISCV_CLINT_H */