mtd: nand: omap: Fix comment in platform data using wrong Kconfig symbol
[linux/fpc-iii.git] / arch / riscv / include / asm / sbi.h
blobb6bb10b92fe24e902c47f68dd377a0af9cd793fc
1 /*
2 * Copyright (C) 2015 Regents of the University of California
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation, version 2.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #ifndef _ASM_RISCV_SBI_H
15 #define _ASM_RISCV_SBI_H
17 #include <linux/types.h>
19 #define SBI_SET_TIMER 0
20 #define SBI_CONSOLE_PUTCHAR 1
21 #define SBI_CONSOLE_GETCHAR 2
22 #define SBI_CLEAR_IPI 3
23 #define SBI_SEND_IPI 4
24 #define SBI_REMOTE_FENCE_I 5
25 #define SBI_REMOTE_SFENCE_VMA 6
26 #define SBI_REMOTE_SFENCE_VMA_ASID 7
27 #define SBI_SHUTDOWN 8
29 #define SBI_CALL(which, arg0, arg1, arg2) ({ \
30 register uintptr_t a0 asm ("a0") = (uintptr_t)(arg0); \
31 register uintptr_t a1 asm ("a1") = (uintptr_t)(arg1); \
32 register uintptr_t a2 asm ("a2") = (uintptr_t)(arg2); \
33 register uintptr_t a7 asm ("a7") = (uintptr_t)(which); \
34 asm volatile ("ecall" \
35 : "+r" (a0) \
36 : "r" (a1), "r" (a2), "r" (a7) \
37 : "memory"); \
38 a0; \
41 /* Lazy implementations until SBI is finalized */
42 #define SBI_CALL_0(which) SBI_CALL(which, 0, 0, 0)
43 #define SBI_CALL_1(which, arg0) SBI_CALL(which, arg0, 0, 0)
44 #define SBI_CALL_2(which, arg0, arg1) SBI_CALL(which, arg0, arg1, 0)
46 static inline void sbi_console_putchar(int ch)
48 SBI_CALL_1(SBI_CONSOLE_PUTCHAR, ch);
51 static inline int sbi_console_getchar(void)
53 return SBI_CALL_0(SBI_CONSOLE_GETCHAR);
56 static inline void sbi_set_timer(uint64_t stime_value)
58 #if __riscv_xlen == 32
59 SBI_CALL_2(SBI_SET_TIMER, stime_value, stime_value >> 32);
60 #else
61 SBI_CALL_1(SBI_SET_TIMER, stime_value);
62 #endif
65 static inline void sbi_shutdown(void)
67 SBI_CALL_0(SBI_SHUTDOWN);
70 static inline void sbi_clear_ipi(void)
72 SBI_CALL_0(SBI_CLEAR_IPI);
75 static inline void sbi_send_ipi(const unsigned long *hart_mask)
77 SBI_CALL_1(SBI_SEND_IPI, hart_mask);
80 static inline void sbi_remote_fence_i(const unsigned long *hart_mask)
82 SBI_CALL_1(SBI_REMOTE_FENCE_I, hart_mask);
85 static inline void sbi_remote_sfence_vma(const unsigned long *hart_mask,
86 unsigned long start,
87 unsigned long size)
89 SBI_CALL_1(SBI_REMOTE_SFENCE_VMA, hart_mask);
92 static inline void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
93 unsigned long start,
94 unsigned long size,
95 unsigned long asid)
97 SBI_CALL_1(SBI_REMOTE_SFENCE_VMA_ASID, hart_mask);
100 #endif