1 /*
2 * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., Ltd. All rights reserved.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #ifndef _REG_IPC_COMREG_H_
16 #define _REG_IPC_COMREG_H_
17
18 #include "reg_access_wrapper.h"
19 #include "chip.h"
20
21 /**
22 * IPC_COMREG registers
23 */
24 #define IPC_COMREG_BASE_ADDR (CS_IPCAPP_BASE + 0x0080)
25
ipc_comreg_get(int idx)26 __STATIC_INLINE uint32_t ipc_comreg_get(int idx)
27 {
28 return PLATFORM_REG_READ(IPC_COMREG_BASE_ADDR + (idx << 2));
29 }
30
ipc_comreg_set(int idx,uint32_t value)31 __STATIC_INLINE void ipc_comreg_set(int idx, uint32_t value)
32 {
33 PLATFORM_REG_WRITE(IPC_COMREG_BASE_ADDR + (idx << 2), value);
34 }
35
36 /**
37 * IPC_COMREG register index definition
38 */
39 enum {
40 IPC_COMREG_STATE = 0,
41 IPC_COMREG_LOWPOWER = 1,
42 IPC_COMREG_WCN_PTA = 2,
43 IPC_COMREG_TWS_HS = 3,
44 IPC_COMREG_TWS_HUS = 4,
45 IPC_COMREG_5 = 5,
46 IPC_COMREG_6 = 6,
47 IPC_COMREG_7 = 7,
48 IPC_COMREG_MAX
49 };
50
51 /**
52 * IPC COMREG STATE register bit definition
53 */
54 #define ICR_STATE_UART0_INITED_POS (0)
55 #define ICR_STATE_UART0_INITED_BIT (0x01UL << ICR_STATE_UART0_INITED_POS)
56 #define ICR_STATE_UART1_INITED_POS (1)
57 #define ICR_STATE_UART1_INITED_BIT (0x01UL << ICR_STATE_UART1_INITED_POS)
58 #define ICR_STATE_UART2_INITED_POS (2)
59 #define ICR_STATE_UART2_INITED_BIT (0x01UL << ICR_STATE_UART2_INITED_POS)
60 #define ICR_STATE_WIFI_IPCSHDENV_ZI_POS (3)
61 #define ICR_STATE_WIFI_IPCSHDENV_ZI_BIT (0x01UL << ICR_STATE_WIFI_IPCSHDENV_ZI_POS)
62 #define ICR_STATE_WIFI_IPCSHDENV_ZI_DONE_POS (4)
63 #define ICR_STATE_WIFI_IPCSHDENV_ZI_DONE_BIT (0x01UL << ICR_STATE_WIFI_IPCSHDENV_ZI_DONE_POS)
64
ipccomreg_state_uart0inited_getb(void)65 __STATIC_INLINE uint8_t ipccomreg_state_uart0inited_getb(void)
66 {
67 return (ipc_comreg_get(IPC_COMREG_STATE) & ICR_STATE_UART0_INITED_BIT) >> ICR_STATE_UART0_INITED_POS;
68 }
69
ipccomreg_state_uart0inited_setb(void)70 __STATIC_INLINE void ipccomreg_state_uart0inited_setb(void)
71 {
72 ipc_comreg_set(IPC_COMREG_STATE, ipc_comreg_get(IPC_COMREG_STATE) | ICR_STATE_UART0_INITED_BIT);
73 }
74
ipccomreg_state_uart0inited_clrb(void)75 __STATIC_INLINE void ipccomreg_state_uart0inited_clrb(void)
76 {
77 ipc_comreg_set(IPC_COMREG_STATE, ipc_comreg_get(IPC_COMREG_STATE) & ~ICR_STATE_UART0_INITED_BIT);
78 }
79
ipccomreg_state_uart1inited_getb(void)80 __STATIC_INLINE uint8_t ipccomreg_state_uart1inited_getb(void)
81 {
82 return (ipc_comreg_get(IPC_COMREG_STATE) & ICR_STATE_UART1_INITED_BIT) >> ICR_STATE_UART1_INITED_POS;
83 }
84
ipccomreg_state_uart1inited_setb(void)85 __STATIC_INLINE void ipccomreg_state_uart1inited_setb(void)
86 {
87 ipc_comreg_set(IPC_COMREG_STATE, ipc_comreg_get(IPC_COMREG_STATE) | ICR_STATE_UART1_INITED_BIT);
88 }
89
ipccomreg_state_uart1inited_clrb(void)90 __STATIC_INLINE void ipccomreg_state_uart1inited_clrb(void)
91 {
92 ipc_comreg_set(IPC_COMREG_STATE, ipc_comreg_get(IPC_COMREG_STATE) & ~ICR_STATE_UART1_INITED_BIT);
93 }
94
ipccomreg_state_uart2inited_getb(void)95 __STATIC_INLINE uint8_t ipccomreg_state_uart2inited_getb(void)
96 {
97 return (ipc_comreg_get(IPC_COMREG_STATE) & ICR_STATE_UART2_INITED_BIT) >> ICR_STATE_UART2_INITED_POS;
98 }
99
ipccomreg_state_uart2inited_setb(void)100 __STATIC_INLINE void ipccomreg_state_uart2inited_setb(void)
101 {
102 ipc_comreg_set(IPC_COMREG_STATE, ipc_comreg_get(IPC_COMREG_STATE) | ICR_STATE_UART2_INITED_BIT);
103 }
104
ipccomreg_state_uart2inited_clrb(void)105 __STATIC_INLINE void ipccomreg_state_uart2inited_clrb(void)
106 {
107 ipc_comreg_set(IPC_COMREG_STATE, ipc_comreg_get(IPC_COMREG_STATE) & ~ICR_STATE_UART2_INITED_BIT);
108 }
109
ipccomreg_state_wifi_ipcshdenv_zi_getb(void)110 __STATIC_INLINE uint8_t ipccomreg_state_wifi_ipcshdenv_zi_getb(void)
111 {
112 return (ipc_comreg_get(IPC_COMREG_STATE) & ICR_STATE_WIFI_IPCSHDENV_ZI_BIT) >> ICR_STATE_WIFI_IPCSHDENV_ZI_POS;
113 }
114
ipccomreg_state_wifi_ipcshdenv_zi_setb(void)115 __STATIC_INLINE void ipccomreg_state_wifi_ipcshdenv_zi_setb(void)
116 {
117 ipc_comreg_set(IPC_COMREG_STATE, ipc_comreg_get(IPC_COMREG_STATE) | ICR_STATE_WIFI_IPCSHDENV_ZI_BIT);
118 }
119
ipccomreg_state_wifi_ipcshdenv_zi_clrb(void)120 __STATIC_INLINE void ipccomreg_state_wifi_ipcshdenv_zi_clrb(void)
121 {
122 ipc_comreg_set(IPC_COMREG_STATE, ipc_comreg_get(IPC_COMREG_STATE) & ~ICR_STATE_WIFI_IPCSHDENV_ZI_BIT);
123 }
124
ipccomreg_state_wifi_ipcshdenv_zi_done_getb(void)125 __STATIC_INLINE uint8_t ipccomreg_state_wifi_ipcshdenv_zi_done_getb(void)
126 {
127 return (ipc_comreg_get(IPC_COMREG_STATE) & ICR_STATE_WIFI_IPCSHDENV_ZI_DONE_BIT) >> ICR_STATE_WIFI_IPCSHDENV_ZI_DONE_POS;
128 }
129
ipccomreg_state_wifi_ipcshdenv_zi_done_setb(void)130 __STATIC_INLINE void ipccomreg_state_wifi_ipcshdenv_zi_done_setb(void)
131 {
132 ipc_comreg_set(IPC_COMREG_STATE, ipc_comreg_get(IPC_COMREG_STATE) | ICR_STATE_WIFI_IPCSHDENV_ZI_DONE_BIT);
133 }
134
ipccomreg_state_wifi_ipcshdenv_zi_done_clrb(void)135 __STATIC_INLINE void ipccomreg_state_wifi_ipcshdenv_zi_done_clrb(void)
136 {
137 ipc_comreg_set(IPC_COMREG_STATE, ipc_comreg_get(IPC_COMREG_STATE) & ~ICR_STATE_WIFI_IPCSHDENV_ZI_DONE_BIT);
138 }
139
140 /**
141 * IPC COMREG LOWPOWER register bit definition
142 */
143 #define ICR_LOWPOWER_WIFI_FW_IDLE_POS (0)
144 #define ICR_LOWPOWER_WIFI_FW_IDLE_BIT (0x01UL << ICR_LOWPOWER_WIFI_FW_IDLE_POS)
145 #define ICR_LOWPOWER_BT_FW_IDLE_POS (1)
146 #define ICR_LOWPOWER_BT_FW_IDLE_BIT (0x01UL << ICR_LOWPOWER_BT_FW_IDLE_POS)
147 #define ICR_LOWPOWER_HOST_IDLE_POS (2)
148 #define ICR_LOWPOWER_HOST_IDLE_BIT (0x01UL << ICR_LOWPOWER_HOST_IDLE_POS)
149 #define ICR_LOWPOWER_BT_FW_INIT_DONE_POS (3)
150 #define ICR_LOWPOWER_BT_FW_INIT_DONE_BIT (0x01UL << ICR_LOWPOWER_BT_FW_INIT_DONE_POS)
151 #define ICR_LOWPOWER_BT_TASK_READY_POS (4)
152 #define ICR_LOWPOWER_BT_TASK_READY_BIT (0x01UL << ICR_LOWPOWER_BT_TASK_READY_POS)
153 #define ICR_LOWPOWER_BT_FW_INIT_START_POS (5)
154 #define ICR_LOWPOWER_BT_FW_INIT_START_BIT (0x01UL << ICR_LOWPOWER_BT_FW_INIT_START_POS)
155 #define ICR_LOWPOWER_DSP_IDLE_POS (6)
156 #define ICR_LOWPOWER_DSP_IDLE_BIT (0x01UL << ICR_LOWPOWER_DSP_IDLE_POS)
157 #define ICR_LOWPOWER_DSP_INIT_DONE_POS (7)
158 #define ICR_LOWPOWER_DSP_INIT_DONE_BIT (0x01UL << ICR_LOWPOWER_DSP_INIT_DONE_POS)
159
ipccomreg_lowpower_wifi_fw_idle_getb(void)160 __STATIC_INLINE uint8_t ipccomreg_lowpower_wifi_fw_idle_getb(void)
161 {
162 return (ipc_comreg_get(IPC_COMREG_LOWPOWER) & ICR_LOWPOWER_WIFI_FW_IDLE_BIT) >> ICR_LOWPOWER_WIFI_FW_IDLE_POS;
163 }
164
ipccomreg_lowpower_wifi_fw_idle_setb(void)165 __STATIC_INLINE void ipccomreg_lowpower_wifi_fw_idle_setb(void)
166 {
167 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) | ICR_LOWPOWER_WIFI_FW_IDLE_BIT);
168 }
169
ipccomreg_lowpower_wifi_fw_idle_clrb(void)170 __STATIC_INLINE void ipccomreg_lowpower_wifi_fw_idle_clrb(void)
171 {
172 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) & ~ICR_LOWPOWER_WIFI_FW_IDLE_BIT);
173 }
174
ipccomreg_lowpower_bt_fw_idle_getb(void)175 __STATIC_INLINE uint8_t ipccomreg_lowpower_bt_fw_idle_getb(void)
176 {
177 return (ipc_comreg_get(IPC_COMREG_LOWPOWER) & ICR_LOWPOWER_BT_FW_IDLE_BIT) >> ICR_LOWPOWER_BT_FW_IDLE_POS;
178 }
179
ipccomreg_lowpower_bt_fw_idle_setb(void)180 __STATIC_INLINE void ipccomreg_lowpower_bt_fw_idle_setb(void)
181 {
182 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) | ICR_LOWPOWER_BT_FW_IDLE_BIT);
183 }
184
ipccomreg_lowpower_bt_fw_idle_clrb(void)185 __STATIC_INLINE void ipccomreg_lowpower_bt_fw_idle_clrb(void)
186 {
187 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) & ~ICR_LOWPOWER_BT_FW_IDLE_BIT);
188 }
189
ipccomreg_lowpower_host_idle_getb(void)190 __STATIC_INLINE uint8_t ipccomreg_lowpower_host_idle_getb(void)
191 {
192 return (ipc_comreg_get(IPC_COMREG_LOWPOWER) & ICR_LOWPOWER_HOST_IDLE_BIT) >> ICR_LOWPOWER_HOST_IDLE_POS;
193 }
194
ipccomreg_lowpower_host_idle_setb(void)195 __STATIC_INLINE void ipccomreg_lowpower_host_idle_setb(void)
196 {
197 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) | ICR_LOWPOWER_HOST_IDLE_BIT);
198 }
199
ipccomreg_lowpower_host_idle_clrb(void)200 __STATIC_INLINE void ipccomreg_lowpower_host_idle_clrb(void)
201 {
202 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) & ~ICR_LOWPOWER_HOST_IDLE_BIT);
203 }
204
ipccomreg_lowpower_bt_fw_init_done_getb(void)205 __STATIC_INLINE uint8_t ipccomreg_lowpower_bt_fw_init_done_getb(void)
206 {
207 return (ipc_comreg_get(IPC_COMREG_LOWPOWER) & ICR_LOWPOWER_BT_FW_INIT_DONE_BIT) >> ICR_LOWPOWER_BT_FW_INIT_DONE_POS;
208 }
209
ipccomreg_lowpower_bt_fw_init_done_setb(void)210 __STATIC_INLINE void ipccomreg_lowpower_bt_fw_init_done_setb(void)
211 {
212 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) | ICR_LOWPOWER_BT_FW_INIT_DONE_BIT);
213 }
214
ipccomreg_lowpower_bt_fw_init_done_clrb(void)215 __STATIC_INLINE void ipccomreg_lowpower_bt_fw_init_done_clrb(void)
216 {
217 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) & ~ICR_LOWPOWER_BT_FW_INIT_DONE_BIT);
218 }
219
ipccomreg_lowpower_bt_task_ready_getb(void)220 __STATIC_INLINE uint8_t ipccomreg_lowpower_bt_task_ready_getb(void)
221 {
222 return (ipc_comreg_get(IPC_COMREG_LOWPOWER) & ICR_LOWPOWER_BT_TASK_READY_BIT) >> ICR_LOWPOWER_BT_TASK_READY_POS;
223 }
224
ipccomreg_lowpower_bt_task_ready_setb(void)225 __STATIC_INLINE void ipccomreg_lowpower_bt_task_ready_setb(void)
226 {
227 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) | ICR_LOWPOWER_BT_TASK_READY_BIT);
228 }
229
ipccomreg_lowpower_bt_task_ready_clrb(void)230 __STATIC_INLINE void ipccomreg_lowpower_bt_task_ready_clrb(void)
231 {
232 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) & ~ICR_LOWPOWER_BT_TASK_READY_BIT);
233 }
234
ipccomreg_lowpower_bt_fw_init_start_getb(void)235 __STATIC_INLINE uint8_t ipccomreg_lowpower_bt_fw_init_start_getb(void)
236 {
237 return (ipc_comreg_get(IPC_COMREG_LOWPOWER) & ICR_LOWPOWER_BT_FW_INIT_START_BIT) >> ICR_LOWPOWER_BT_FW_INIT_START_POS;
238 }
239
ipccomreg_lowpower_bt_fw_init_start_setb(void)240 __STATIC_INLINE void ipccomreg_lowpower_bt_fw_init_start_setb(void)
241 {
242 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) | ICR_LOWPOWER_BT_FW_INIT_START_BIT);
243 }
244
ipccomreg_lowpower_bt_fw_init_start_clrb(void)245 __STATIC_INLINE void ipccomreg_lowpower_bt_fw_init_start_clrb(void)
246 {
247 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) & ~ICR_LOWPOWER_BT_FW_INIT_START_BIT);
248 }
249
ipccomreg_lowpower_dsp_idle_getb(void)250 __STATIC_INLINE uint8_t ipccomreg_lowpower_dsp_idle_getb(void)
251 {
252 return (ipc_comreg_get(IPC_COMREG_LOWPOWER) & ICR_LOWPOWER_DSP_IDLE_BIT) >> ICR_LOWPOWER_DSP_IDLE_POS;
253 }
254
ipccomreg_lowpower_dsp_idle_setb(void)255 __STATIC_INLINE void ipccomreg_lowpower_dsp_idle_setb(void)
256 {
257 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) | ICR_LOWPOWER_DSP_IDLE_BIT);
258 }
259
ipccomreg_lowpower_dsp_idle_clrb(void)260 __STATIC_INLINE void ipccomreg_lowpower_dsp_idle_clrb(void)
261 {
262 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) & ~ICR_LOWPOWER_DSP_IDLE_BIT);
263 }
264
ipccomreg_lowpower_dsp_init_done_getb(void)265 __STATIC_INLINE uint8_t ipccomreg_lowpower_dsp_init_done_getb(void)
266 {
267 return (ipc_comreg_get(IPC_COMREG_LOWPOWER) & ICR_LOWPOWER_DSP_INIT_DONE_BIT) >> ICR_LOWPOWER_DSP_INIT_DONE_POS;
268 }
269
ipccomreg_lowpower_dsp_init_done_setb(void)270 __STATIC_INLINE void ipccomreg_lowpower_dsp_init_done_setb(void)
271 {
272 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) | ICR_LOWPOWER_DSP_INIT_DONE_BIT);
273 }
274
ipccomreg_lowpower_dsp_init_done_clrb(void)275 __STATIC_INLINE void ipccomreg_lowpower_dsp_init_done_clrb(void)
276 {
277 ipc_comreg_set(IPC_COMREG_LOWPOWER, ipc_comreg_get(IPC_COMREG_LOWPOWER) & ~ICR_LOWPOWER_DSP_INIT_DONE_BIT);
278 }
279
280 /**
281 * IPC COMREG WCN PTA register bit definition
282 */
283
ipccomreg_wcn_pta_get(void)284 __STATIC_INLINE uint32_t ipccomreg_wcn_pta_get(void)
285 {
286 return ipc_comreg_get(IPC_COMREG_WCN_PTA);
287 }
288
ipccomreg_wcn_pta_set(uint32_t value)289 __STATIC_INLINE void ipccomreg_wcn_pta_set(uint32_t value)
290 {
291 ipc_comreg_set(IPC_COMREG_WCN_PTA, value);
292 }
293
ipccomreg_tws_hs_get(void)294 __STATIC_INLINE uint32_t ipccomreg_tws_hs_get(void)
295 {
296 return ipc_comreg_get(IPC_COMREG_TWS_HS);
297 }
298
ipccomreg_tws_hs_set(uint32_t value)299 __STATIC_INLINE void ipccomreg_tws_hs_set(uint32_t value)
300 {
301 ipc_comreg_set(IPC_COMREG_TWS_HS, value);
302 }
303
ipccomreg_tws_hus_get(void)304 __STATIC_INLINE uint32_t ipccomreg_tws_hus_get(void)
305 {
306 return ipc_comreg_get(IPC_COMREG_TWS_HUS);
307 }
308
ipccomreg_tws_hus_set(uint32_t value)309 __STATIC_INLINE void ipccomreg_tws_hus_set(uint32_t value)
310 {
311 ipc_comreg_set(IPC_COMREG_TWS_HUS, value);
312 }
313
314 #endif /* _REG_IPC_COMREG_H_ */
315