blob: dfe834c7c22f11bf33926b357b554a52c58c2728 [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001#ifndef __DRV_RSTCTL_H__
2#define __DRV_RSTCTL_H__
3
4#include "cpu_info.h" // for SYS_MCU_NUM_VPE
5
6/*Set wdt1 timeout interval as 30 sec(32768*15=0xF0000)*/
7/*Set wdt2 timeout interval as 40 secs (32768*16) = 0x80000*/
8/*Reason to change this vlaue: to distinguish system is WDT reset or simply reboot*/
9#define WDT_RSTINTERVAL_VALUE (0x0F0000)
10#define WDT_RSTINTERVAL_VALUE2 (0x140000)
11
12#define VPE_NUM (SYS_MCU_NUM_VPE)
13
14typedef enum
15{
16 VPE0 = 0,
17 VPE1,
18 VPE2,
19 VPE3,
20 VPE4,
21 VPE5,
22 VPE6,
23 VPE7,
24 VPE8,
25 VPE9,
26 VPE10,
27 VPE11,
28}vpeid_e;
29
30
31/*For RGU framework purpose. */
32
33typedef enum{
34 UT_REPORT_FAIL = -1,
35 UT_REPORT_PASS = 0,
36 UT_REPORT_NA
37}UT_REPORT_STATUS;
38
39
40typedef UT_REPORT_STATUS (*ut_testcase_fn_ptr)(kal_uint32 flags, void *param);
41
42
43typedef struct
44{
45 ut_testcase_fn_ptr _main_fn;
46 kal_uint32 flags;
47 void *para;
48 kal_char *description;
49 kal_char *testplan_section;
50}ut_testcase_struct;
51
52
53typedef enum
54{
55 APSYS = 8,
56 MD1SYS = 4,
57 ARM7SYS = 2,
58 L1SYS = 1
59}subsystem_e;
60
61
62/*For software reset purpose. */
63typedef enum
64{
65 RST_TARGET_MIN=0,
66
67 RST_IA_LOGGER,
68 RST_MDUART0,
69 RST_MDUART1,
70 RST_SOE,
71 RST_USIM1,
72 RST_USIM2,
73 RST_GPT,
74 RST_MDTOPSM,
75 RST_MDOST,
76 RST_TRACE,
77 RST_L1SYS,
78 RST_MML2,
79
80 /* Below enums in Gen93 is for dummy */
81 RST_MDGDMA, //MDPERI:0
82 RST_MDGPTM, //MDPERI:4
83 RST_MDMISC, //MDPERI:5
84 RST_MDCIRQ, //MDPERI:6
85 RST_I2C, //MDPERI:7
86 RST_MDDBGSYS, //MDPERI:8
87 RST_MDDBGSIB, //MDPERI:9
88 //RST_GPIOMUX, //Remove in ELBRUS
89 RST_MDEINT, //MDPERI:10 New in ELBRUS
90 RST_MDCFGCTL, //MDPERI:13
91 RST_MDECT, //MDPERI:14 !!NEW!!
92 RST_MDECTDBG, //MDPERI:15 !!NEW!!
93 RST_MDCLKBUS, //MDPERI:16 !!NEW!!
94 RST_MDCLK, //MDPERI:17 !!NEW!!
95 RST_PSLITE_GPT, //MDPERI:19 !!NEW!!
96 //RST_ARM7_PCCIF, //Remove in ELBRUS
97 RST_SDF, //MDPERI:20 New in ELBRUS
98 RST_THERM, //MDPERI:21 New in ELBRUS
99 RST_MDGPTM_L1, //MDPERI:23 New in ELBRUS
100 RST_PSLITE_GPT_L1, //MDPERI:24 New in ELBRUS
101
102 RST_MDINFRA_BUSMON, //MDINFRA:0
103 //RST_MDINFRA_BOOTROM, //Remove in ELBRUS
104 //RST_ABM, //Remove in ELBRUS
105 RST_MDUART2, //MDINFRA:2
106 RST_PSPERI, //MDINFRA:3
107 RST_BUS_RECORD, //MDINFRA:4
108 RST_MDMCU_PCCIF, //MDINFRA:6 New in ELBRUS
109 RST_CK208M, //MDINFRA:7 New in ELBRUS
110 RST_CK150M, //MDINFRA:8 New in ELBRUS
111 RST_PPC, //MDINFRA:9 New in ELBRUS
112 RST_MDINFRA_MDMISC, //MDINFRA:10 New in ELBRUS
113 RST_LOGGDMA, //MDINFRA:11 New in ELBRUS
114 RST_MDINFRA_ABM, //MDINFRA:12 New in ELBRUS
115 RST_MDINFRA_ELM, //MDINFRA:13 New in ELBRUS
116
117 RST_MIPS_DBG, //MDMCU: 0
118 RST_MIPS_NRESET, //MDMCU: 1
119 RST_MIPS_BUSMON, //MDMCU: 2
120 //RST_PF, //Remove in ELBRUS
121 //RST_PCMON_FIFO, //Remove in ELBRUS
122 RST_PCMON_REG, //MDMCU: 3
123 RST_ABM, //MDMCU: 4 New in ELBRUS
124 RST_ELM, //MDMCU: 5 New in ELBRUS
125 RST_MOBR, //MDMCU: 6 New in ELBRUS
126 RST_MMBR, //MDMCU: 7 New in ELBRUS
127 RST_L2SRAM, //MDMCU: 8 New in ELBRUS
128 RST_ULS, //MDMCU: 9 New in ELBRUS
129 RST_IOCU_ELM, //MDMCU: 10 New in ELBRUS
130
131 RST_L2COP, //LTEL2: 0
132
133 RST_HSPAL2, //HSPAL2: 0
134 RST_TARGET_MAX, /**< Maximum value of reset item : for correctness check */
135 RST_NULL, //Used in drv_UT_within_RGU_framework. Some IPs do not tolerate software while programe is running.
136
137
138 RST_BSI_ALL,
139 RST_MDALL,
140
141 RST_MDALL_WO_SPI,
142 RST_MDALL_WO_USB,
143 RST_MDALL_WO_GPIO,
144 RST_CLDMA, //for Yts'sreset CLDMA
145 RST_CLDMA_AO //for Yts'sreset CLDMA
146} rst_target_e;
147
148typedef enum
149{
150 WDT_RESET,
151 WDT_IRQ_ONLY,
152} wdt_irq_e;
153
154typedef enum
155{
156 WDT,
157 AUX_WDT,
158} wdt_e;
159
160typedef enum
161{
162 RST_MIPS_LOCK = 0,
163 RST_MIPS_UNLOCK = 1,
164}rst_mips_lock_e;
165
166
167/*****************************************************************************
168 * function declaration *
169 *****************************************************************************/
170
171extern kal_bool drv_rstctl_sw_reset(rst_target_e targetIP);
172
173
174/*************************************************************************
175* FUNCTION
176* drv_rstctl_wdt_reset
177*
178* DESCRIPTION
179* This function is to do wdt reset
180*
181* PARAMETERS
182* none
183*
184* RETURN VALUES
185* none
186*
187*************************************************************************/
188extern void drv_rstctl_wdt_reset(void);
189
190extern void drv_rstctl_wdt_reset_aux(void);
191
192
193/*************************************************************************
194* FUNCTION
195* drv_rstctl_wdt_abnReset
196*
197* DESCRIPTION
198* This function is used to do abnormal reset
199*
200* PARAMETERS
201* none
202*
203* RETURN VALUES
204* none
205*
206*************************************************************************/
207extern void drv_rstctl_wdt_abnReset(void);
208
209/*************************************************************************
210* FUNCTION
211* drv_rstctl_wdt_enableInterrupt
212*
213* DESCRIPTION
214* This function is used to on/off irq mode
215* reset or trigger interrupt while watchdog timout happening
216*
217* PARAMETERS
218* none
219*
220* RETURN VALUES
221* none
222*
223*************************************************************************/
224extern void drv_rstctl_wdt_enableInterrupt(kal_bool enable);
225
226extern void drv_rstctl_wdt_enableInterrupt_aux(kal_bool enable);
227
228
229/*************************************************************************
230* FUNCTION
231* drv_rstctl_wd_clrSta
232*
233* DESCRIPTION
234* This function is used to get wd timer interval(uint:512*T(32k))
235*
236* PARAMETERS
237* none
238*
239* RETURN VALUES
240* none
241*************************************************************************/
242extern kal_uint32 drv_rstctl_wd_getInterval(void);
243
244extern kal_uint32 drv_rstctl_wd_getInterval_aux(void);
245
246
247/*************************************************************************
248* FUNCTION
249* drv_rstctl_wd_clrCnt
250*
251* DESCRIPTION
252* This function is used to clear wdt cnt
253*
254* PARAMETERS
255* cntMaskToClear
256* 0: clear both AP/MD WD Cnt
257* MD_WDCNT_CLR: clear MD WD Cnt
258* AP_WDCNT_CLR: clear AP WD Cnt
259*
260* RETURN VALUES
261* none
262*************************************************************************/
263//extern void drv_rstctl_wd_clrCnt(kal_uint32 cntMaskToClear);
264
265/*************************************************************************
266* FUNCTION
267* drv_rstctl_wdt_setInterval
268*
269* DESCRIPTION
270* This function is used to set wd tiemr
271*
272* PARAMETERS
273* none
274*
275* RETURN VALUES
276* none
277*
278* NOTE
279* Need to restart wdt timer to apply this value
280*************************************************************************/
281extern void drv_rstctl_wdt_setInterval(kal_uint32 wdtInterval);
282
283extern void drv_rstctl_wdt_setInterval_aux(kal_uint32 wdtInterval);
284
285
286/*************************************************************************
287* FUNCTION
288* drv_rstctl_wd_kick
289*
290* DESCRIPTION
291* This function is used to retart wd tiemr
292*
293* PARAMETERS
294* none
295*
296* RETURN VALUES
297* none
298*************************************************************************/
299extern void drv_rstctl_restartWDT(void);
300
301/*************************************************************************
302* FUNCTION
303* drv_rstctl_wdt_init
304*
305* DESCRIPTION
306* This function is to initialize the WDT module
307*
308* PARAMETERS
309* none
310*
311* RETURN VALUES
312* none
313*
314*************************************************************************/
315extern void drv_rstctl_wdt_init(void);
316
317extern void drv_rstctl_wdt_init_aux(void);
318
319
320/*************************************************************************
321* FUNCTION
322* drv_rstctl_wdt_enableDebugMode
323*
324* DESCRIPTION
325* This function is used to on/off debug mode
326*
327* PARAMETERS
328* cntMaskToClear
329* 0: clear both AP/MD WD Cnt
330* MD_WDCNT_CLR: clear MD WD Cnt
331* AP_WDCNT_CLR: clear AP WD Cnt
332*
333* RETURN VALUES
334* none
335*************************************************************************/
336extern void drv_rstctl_wdt_enableDebugMode(kal_bool enable);
337
338/*************************************************************************
339* FUNCTION
340* drv_rstctl_wdt_enable
341*
342* DESCRIPTION
343* This function is used to on/off wd timer
344*
345* PARAMETERS
346* none
347*
348* RETURN VALUES
349* none
350*
351* NOTE
352* Need to restart wdt timer to apply this value
353*************************************************************************/
354extern void drv_rstctl_wdt_enable(kal_bool en);
355
356extern void drv_rstctl_wdt_enable_aux(kal_bool en);
357
358extern void drv_rstctl_set_check_bit(vpeid_e vpe);
359
360extern void drv_rstctl_clr_check_bit(vpeid_e vpe);
361
362extern void drv_rstctl_set_kick_bit(vpeid_e vpe);
363
364extern void drv_rstctl_clr_kick_bit(vpeid_e vpe);
365
366/*************************************************************************
367* FUNCTION
368* drv_rstctl_disable_all_WDTs
369*
370* DESCRIPTION
371* This function is used to disable all WDTs (APRGU, MDRGU, L1RGU, ARM7RGU)
372*
373*
374* PARAMETERS
375* None.
376*
377* RETURN VALUES
378* KAL_TRUE: SUCCESSFULY disable all WDTs.
379* KAL_FALSE: FAIL to disable all WDTs.
380*
381* NOTE
382*************************************************************************/
383extern kal_bool drv_rstctl_disable_all_WDTs(void);
384
385
386/*************************************************************************
387* FUNCTION
388* drv_rstctl_A7_unlock
389*
390* DESCRIPTION
391* This function is used to unlock ARM7 hrst
392*
393* PARAMETERS
394* lock: RST_A7_LOCK:
395* RST_A7_UNLOCK:
396*
397* RETURN VALUES
398* none
399*
400*************************************************************************/
401
402void drv_rstctl_MIPS_unlock(rst_mips_lock_e lock);
403
404extern void mips_isr_mdwdt_handler(void);
405
406extern void invalidate_WDTBASE(void);
407
408extern UT_REPORT_STATUS drv_UT_within_RGU_framework(rst_target_e targetIP, subsystem_e target_system, subsystem_e system_coverage,
409 ut_testcase_struct *testcase_ptr, kal_uint32 test_items, kal_uint32 delay_cycles);
410/*
411kal_uint32 Get_WATCHDOG_BASE(void);
412
413kal_uint32 Get_WATCHDOG_RESTART_CMD(void);
414*/
415kal_bool Is_WDT_Init(void);
416
417void WDT_init(void);
418void wdt_enable(kal_bool en);
419
420extern const kal_uint32 g_WATCHDOG_RESTART_REG;
421extern const kal_uint32 g_WATCHDOG_CTL_REG;
422extern const kal_uint32 g_WATCHDOG_RESTART_VALUE;
423extern const kal_uint32 g_ABNORMAL_RST_REG;
424extern const kal_uint32 g_ABNORMAL_RST_VAL;
425
426#endif /* end of __DRV_RSTCLT_H__ */
427