Debian Codegraph @

ports/renesas-ra/ra/ra_utils.h

raw
1 /*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2021-2023 Renesas Electronics Corporation
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25 #ifndef RA_RA_UTILS_H_
26 #define RA_RA_UTILS_H_
27
28 #include <stdint.h>
29 #include <stdbool.h>
30
31 __attribute__((always_inline)) static inline void ra_enable_irq(__attribute__((unused)) uint32_t state) {
32 __asm__ volatile ("cpsie f"
33 :
34 :
35 : "memory");
36 }
37
38 __attribute__((always_inline)) static inline uint32_t ra_disable_irq(void) {
39 uint32_t state;
40 __asm__ volatile ("cpsid f"
41 : "=r" (state)
42 :
43 : "memory");
44 return state;
45 }
46
47 void ra_mstpcra_stop(uint32_t mod_mask);
48 void ra_mstpcra_start(uint32_t mod_mask);
49 void ra_mstpcrb_stop(uint32_t mod_mask);
50 void ra_mstpcrb_start(uint32_t mod_mask);
51 void ra_mstpcrc_stop(uint32_t mod_mask);
52 void ra_mstpcrc_start(uint32_t mod_mask);
53 void ra_mstpcrd_stop(uint32_t mod_mask);
54 void ra_mstpcrd_start(uint32_t mod_mask);
55 void ra_mstpcre_stop(uint32_t mod_mask);
56 void ra_mstpcre_start(uint32_t mod_mask);
57
58 /* mask bit definition for Module Stop Control Register B */
59 #ifndef R_MSTP_MSTPCRB_MSTPB7_Msk
60 #define R_MSTP_MSTPCRB_MSTPB7_Msk (0x1UL << 7)
61 #endif
62 #ifndef R_MSTP_MSTPCRB_MSTPB8_Msk
63 #define R_MSTP_MSTPCRB_MSTPB8_Msk (0x1UL << 8)
64 #endif
65 #ifndef R_MSTP_MSTPCRB_MSTPB9_Msk
66 #define R_MSTP_MSTPCRB_MSTPB9_Msk (0x1UL << 9)
67 #endif
68 #ifndef R_MSTP_MSTPCRB_MSTPB18_Msk
69 #define R_MSTP_MSTPCRB_MSTPB18_Msk (0x1UL << 18)
70 #endif
71 #ifndef R_MSTP_MSTPCRB_MSTPB19_Msk
72 #define R_MSTP_MSTPCRB_MSTPB19_Msk (0x1UL << 19)
73 #endif
74 #ifndef R_MSTP_MSTPCRB_MSTPB22_Msk
75 #define R_MSTP_MSTPCRB_MSTPB22_Msk (0x1UL << 22)
76 #endif
77 #ifndef R_MSTP_MSTPCRB_MSTPB23_Msk
78 #define R_MSTP_MSTPCRB_MSTPB23_Msk (0x1UL << 23)
79 #endif
80 #ifndef R_MSTP_MSTPCRB_MSTPB24_Msk
81 #define R_MSTP_MSTPCRB_MSTPB24_Msk (0x1UL << 24)
82 #endif
83 #ifndef R_MSTP_MSTPCRB_MSTPB25_Msk
84 #define R_MSTP_MSTPCRB_MSTPB25_Msk (0x1UL << 25)
85 #endif
86 #ifndef R_MSTP_MSTPCRB_MSTPB26_Msk
87 #define R_MSTP_MSTPCRB_MSTPB26_Msk (0x1UL << 26)
88 #endif
89 #ifndef R_MSTP_MSTPCRB_MSTPB27_Msk
90 #define R_MSTP_MSTPCRB_MSTPB27_Msk (0x1UL << 27)
91 #endif
92 #ifndef R_MSTP_MSTPCRB_MSTPB28_Msk
93 #define R_MSTP_MSTPCRB_MSTPB28_Msk (0x1UL << 28)
94 #endif
95 #ifndef R_MSTP_MSTPCRB_MSTPB29_Msk
96 #define R_MSTP_MSTPCRB_MSTPB29_Msk (0x1UL << 29)
97 #endif
98 #ifndef R_MSTP_MSTPCRB_MSTPB30_Msk
99 #define R_MSTP_MSTPCRB_MSTPB30_Msk (0x1UL << 30)
100 #endif
101 #ifndef R_MSTP_MSTPCRB_MSTPB31_Msk
102 #define R_MSTP_MSTPCRB_MSTPB31_Msk (0x1UL << 31)
103 #endif
104
105 /* mask bit definition for Module Stop Control Register D */
106 #ifndef R_MSTP_MSTPCRD_MSTPD2_Msk
107 #define R_MSTP_MSTPCRD_MSTPD2_Msk (0x1UL << 2)
108 #endif
109 #ifndef R_MSTP_MSTPCRD_MSTPD3_Msk
110 #define R_MSTP_MSTPCRD_MSTPD3_Msk (0x1UL << 3)
111 #endif
112 #ifndef R_MSTP_MSTPCRD_MSTPD5_Msk
113 #define R_MSTP_MSTPCRD_MSTPD5_Msk (0x1UL << 5)
114 #endif
115 #ifndef R_MSTP_MSTPCRD_MSTPD6_Msk
116 #define R_MSTP_MSTPCRD_MSTPD6_Msk (0x1UL << 6)
117 #endif
118 #ifndef R_MSTP_MSTPCRD_MSTPD15_Msk
119 #define R_MSTP_MSTPCRD_MSTPD15_Msk (0x1UL << 15)
120 #endif
121 #ifndef R_MSTP_MSTPCRD_MSTPD16_Msk
122 #define R_MSTP_MSTPCRD_MSTPD16_Msk (0x1UL << 16)
123 #endif
124 #ifndef R_MSTP_MSTPCRD_MSTPD20_Msk
125 #define R_MSTP_MSTPCRD_MSTPD20_Msk (0x1UL << 20)
126 #endif
127 #ifndef R_MSTP_MSTPCRD_MSTPD22_Msk
128 #define R_MSTP_MSTPCRD_MSTPD22_Msk (0x1UL << 22)
129 #endif
130
131 #endif /* RA_RA_UTILS_H_ */