mtd: nand: omap: Fix comment in platform data using wrong Kconfig symbol
[linux/fpc-iii.git] / arch / riscv / include / asm / csr.h
blob28a0d1cb374c8c25ce4032da874b974712ca3129
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_CSR_H
15 #define _ASM_RISCV_CSR_H
17 #include <linux/const.h>
19 /* Status register flags */
20 #define SR_SIE _AC(0x00000002, UL) /* Supervisor Interrupt Enable */
21 #define SR_SPIE _AC(0x00000020, UL) /* Previous Supervisor IE */
22 #define SR_SPP _AC(0x00000100, UL) /* Previously Supervisor */
23 #define SR_SUM _AC(0x00040000, UL) /* Supervisor may access User Memory */
25 #define SR_FS _AC(0x00006000, UL) /* Floating-point Status */
26 #define SR_FS_OFF _AC(0x00000000, UL)
27 #define SR_FS_INITIAL _AC(0x00002000, UL)
28 #define SR_FS_CLEAN _AC(0x00004000, UL)
29 #define SR_FS_DIRTY _AC(0x00006000, UL)
31 #define SR_XS _AC(0x00018000, UL) /* Extension Status */
32 #define SR_XS_OFF _AC(0x00000000, UL)
33 #define SR_XS_INITIAL _AC(0x00008000, UL)
34 #define SR_XS_CLEAN _AC(0x00010000, UL)
35 #define SR_XS_DIRTY _AC(0x00018000, UL)
37 #ifndef CONFIG_64BIT
38 #define SR_SD _AC(0x80000000, UL) /* FS/XS dirty */
39 #else
40 #define SR_SD _AC(0x8000000000000000, UL) /* FS/XS dirty */
41 #endif
43 /* SATP flags */
44 #if __riscv_xlen == 32
45 #define SATP_PPN _AC(0x003FFFFF, UL)
46 #define SATP_MODE_32 _AC(0x80000000, UL)
47 #define SATP_MODE SATP_MODE_32
48 #else
49 #define SATP_PPN _AC(0x00000FFFFFFFFFFF, UL)
50 #define SATP_MODE_39 _AC(0x8000000000000000, UL)
51 #define SATP_MODE SATP_MODE_39
52 #endif
54 /* Interrupt Enable and Interrupt Pending flags */
55 #define SIE_SSIE _AC(0x00000002, UL) /* Software Interrupt Enable */
56 #define SIE_STIE _AC(0x00000020, UL) /* Timer Interrupt Enable */
57 #define SIE_SEIE _AC(0x00000200, UL) /* External Interrupt Enable */
59 #define EXC_INST_MISALIGNED 0
60 #define EXC_INST_ACCESS 1
61 #define EXC_BREAKPOINT 3
62 #define EXC_LOAD_ACCESS 5
63 #define EXC_STORE_ACCESS 7
64 #define EXC_SYSCALL 8
65 #define EXC_INST_PAGE_FAULT 12
66 #define EXC_LOAD_PAGE_FAULT 13
67 #define EXC_STORE_PAGE_FAULT 15
69 #ifndef __ASSEMBLY__
71 #define csr_swap(csr, val) \
72 ({ \
73 unsigned long __v = (unsigned long)(val); \
74 __asm__ __volatile__ ("csrrw %0, " #csr ", %1" \
75 : "=r" (__v) : "rK" (__v) \
76 : "memory"); \
77 __v; \
80 #define csr_read(csr) \
81 ({ \
82 register unsigned long __v; \
83 __asm__ __volatile__ ("csrr %0, " #csr \
84 : "=r" (__v) : \
85 : "memory"); \
86 __v; \
89 #define csr_write(csr, val) \
90 ({ \
91 unsigned long __v = (unsigned long)(val); \
92 __asm__ __volatile__ ("csrw " #csr ", %0" \
93 : : "rK" (__v) \
94 : "memory"); \
97 #define csr_read_set(csr, val) \
98 ({ \
99 unsigned long __v = (unsigned long)(val); \
100 __asm__ __volatile__ ("csrrs %0, " #csr ", %1" \
101 : "=r" (__v) : "rK" (__v) \
102 : "memory"); \
103 __v; \
106 #define csr_set(csr, val) \
107 ({ \
108 unsigned long __v = (unsigned long)(val); \
109 __asm__ __volatile__ ("csrs " #csr ", %0" \
110 : : "rK" (__v) \
111 : "memory"); \
114 #define csr_read_clear(csr, val) \
115 ({ \
116 unsigned long __v = (unsigned long)(val); \
117 __asm__ __volatile__ ("csrrc %0, " #csr ", %1" \
118 : "=r" (__v) : "rK" (__v) \
119 : "memory"); \
120 __v; \
123 #define csr_clear(csr, val) \
124 ({ \
125 unsigned long __v = (unsigned long)(val); \
126 __asm__ __volatile__ ("csrc " #csr ", %0" \
127 : : "rK" (__v) \
128 : "memory"); \
131 #endif /* __ASSEMBLY__ */
133 #endif /* _ASM_RISCV_CSR_H */