nds32: Fix building error of crypto/xor.c by adding xor.h
[linux-2.6-microblaze.git] / arch / nds32 / include / asm / nds32.h
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (C) 2005-2017 Andes Technology Corporation
3
4 #ifndef _ASM_NDS32_NDS32_H_
5 #define _ASM_NDS32_NDS32_H_
6
7 #include <asm/bitfield.h>
8 #include <asm/cachectl.h>
9
10 #ifndef __ASSEMBLY__
11 #include <linux/init.h>
12 #include <asm/barrier.h>
13 #include <nds32_intrinsic.h>
14
15 #ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
16 #define FP_OFFSET (-3)
17 #else
18 #define FP_OFFSET (-2)
19 #endif
20
21 extern void __init early_trap_init(void);
22 static inline void GIE_ENABLE(void)
23 {
24         mb();
25         __nds32__gie_en();
26 }
27
28 static inline void GIE_DISABLE(void)
29 {
30         mb();
31         __nds32__gie_dis();
32 }
33
34 static inline unsigned long CACHE_SET(unsigned char cache)
35 {
36
37         if (cache == ICACHE)
38                 return 64 << ((__nds32__mfsr(NDS32_SR_ICM_CFG) & ICM_CFG_mskISET) >>
39                               ICM_CFG_offISET);
40         else
41                 return 64 << ((__nds32__mfsr(NDS32_SR_DCM_CFG) & DCM_CFG_mskDSET) >>
42                               DCM_CFG_offDSET);
43 }
44
45 static inline unsigned long CACHE_WAY(unsigned char cache)
46 {
47
48         if (cache == ICACHE)
49                 return 1 +
50                     ((__nds32__mfsr(NDS32_SR_ICM_CFG) & ICM_CFG_mskIWAY) >> ICM_CFG_offIWAY);
51         else
52                 return 1 +
53                     ((__nds32__mfsr(NDS32_SR_DCM_CFG) & DCM_CFG_mskDWAY) >> DCM_CFG_offDWAY);
54 }
55
56 static inline unsigned long CACHE_LINE_SIZE(unsigned char cache)
57 {
58
59         if (cache == ICACHE)
60                 return 8 <<
61                     (((__nds32__mfsr(NDS32_SR_ICM_CFG) & ICM_CFG_mskISZ) >> ICM_CFG_offISZ) - 1);
62         else
63                 return 8 <<
64                     (((__nds32__mfsr(NDS32_SR_DCM_CFG) & DCM_CFG_mskDSZ) >> DCM_CFG_offDSZ) - 1);
65 }
66
67 #endif /* __ASSEMBLY__ */
68
69 #define IVB_BASE                PHYS_OFFSET     /* in user space for intr/exc/trap/break table base, 64KB aligned
70                                                  * We defined at the start of the physical memory */
71
72 /* dispatched sub-entry exception handler numbering */
73 #define RD_PROT                 0       /* read protrection */
74 #define WRT_PROT                1       /* write protection */
75 #define NOEXEC                  2       /* non executable */
76 #define PAGE_MODIFY             3       /* page modified */
77 #define ACC_BIT                 4       /* access bit */
78 #define RESVED_PTE              5       /* reserved PTE attribute */
79 /* reserved 6 ~ 16 */
80
81 #endif /* _ASM_NDS32_NDS32_H_ */