blob: a279b17a6aade915d0f330247a02387515837da0 [file] [log] [blame]
Christoph Hellwigfcdc6532019-10-28 13:10:38 +01001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _ASM_RISCV_CLINT_H
3#define _ASM_RISCV_CLINT_H 1
4
5#include <linux/io.h>
6#include <linux/smp.h>
7
8#ifdef CONFIG_RISCV_M_MODE
9extern u32 __iomem *clint_ipi_base;
10
11void clint_init_boot_cpu(void);
12
13static inline void clint_send_ipi_single(unsigned long hartid)
14{
15 writel(1, clint_ipi_base + hartid);
16}
17
Greentime Hu3384b042020-03-03 17:34:18 +080018static inline void clint_send_ipi_mask(const struct cpumask *mask)
Christoph Hellwigfcdc6532019-10-28 13:10:38 +010019{
Greentime Hu3384b042020-03-03 17:34:18 +080020 int cpu;
Christoph Hellwigfcdc6532019-10-28 13:10:38 +010021
Greentime Hu3384b042020-03-03 17:34:18 +080022 for_each_cpu(cpu, mask)
23 clint_send_ipi_single(cpuid_to_hartid_map(cpu));
Christoph Hellwigfcdc6532019-10-28 13:10:38 +010024}
25
26static inline void clint_clear_ipi(unsigned long hartid)
27{
28 writel(0, clint_ipi_base + hartid);
29}
30#else /* CONFIG_RISCV_M_MODE */
31#define clint_init_boot_cpu() do { } while (0)
32
33/* stubs to for code is only reachable under IS_ENABLED(CONFIG_RISCV_M_MODE): */
34void clint_send_ipi_single(unsigned long hartid);
35void clint_send_ipi_mask(const struct cpumask *hartid_mask);
36void clint_clear_ipi(unsigned long hartid);
37#endif /* CONFIG_RISCV_M_MODE */
38
39#endif /* _ASM_RISCV_CLINT_H */