blob: aa86503e59479a26334dba6eb1df6dddeae4c99e [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001/*****************************************************************************
2* Copyright Statement:
3* --------------------
4* This software is protected by Copyright and the information contained
5* herein is confidential. The software may not be copied and the information
6* contained herein may not be used or disclosed except with the written
7* permission of MediaTek Inc. (C) 2001
8*
9*****************************************************************************/
10
11/*****************************************************************************
12 *
13 * Filename:
14 * ---------
15 * dcl_wdt.h
16 *
17 * Project:
18 * --------
19 * Maui
20 *
21 * Description:
22 * ------------
23 * Header file of DCL (Driver Common Layer) for WDT.
24 *
25 * Author:
26 * -------
27 * -------
28 *
29 *============================================================================
30 * HISTORY
31 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
32 *------------------------------------------------------------------------------
33 * removed!
34 * removed!
35 * removed!
36 *
37 * removed!
38 * removed!
39 * removed!
40 *
41 * removed!
42 * removed!
43 * removed!
44 *
45 * removed!
46 * removed!
47 * removed!
48 *
49 * removed!
50 * removed!
51 * removed!
52 *
53 * removed!
54 * removed!
55 * removed!
56 *
57 * removed!
58 * removed!
59 * removed!
60 *
61 * removed!
62 * removed!
63 * removed!
64 *
65 * removed!
66 * removed!
67 * removed!
68 *
69 * removed!
70 * removed!
71 * removed!
72 *
73 * removed!
74 * removed!
75 *
76 *
77 *------------------------------------------------------------------------------
78 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
79 *============================================================================
80 ****************************************************************************/
81
82#ifdef DCL_DEFINITION_STRUCT
83#ifndef __DCL_WDT_H_STRUCT__
84#define __DCL_WDT_H_STRUCT__
85
86
87#define DCL_WDT_RSTINTERVAL_VALUE 0xffa
88
89/*******************************************************************************
90 * DCL_OPTIONS for WDT
91 *******************************************************************************/
92#define WDT_OPTIONS
93
94 /*******************************************************************************
95 * DCL_CONFIGURE_T for WDT
96 *******************************************************************************/
97
98#define WDT_CONFIGS
99
100/*******************************************************************************
101 * DCL_EVENT for WDT
102 *******************************************************************************/
103#ifdef __BUILD_DOM__
104/*The WDT EVENT is part of DCL_EVENT_T Enum of dcl.h*/
105/*WDT_EVENTS_T Define the event type that wdt support to register a callback function*/
106typedef enum
107{
108 EVENT_WDT_TIMEOUT = 0x00000001
109}DCL_EVENT_T;
110#else
111#define WDT_EVENTS \
112 EVENT_WDT_TIMEOUT = 0x00000001,
113#endif
114/*******************************************************************************
115 * DCL_CTRL_CMD for WDT
116 *******************************************************************************/
117#ifdef __BUILD_DOM__
118/*The WDT Command values is part of DCL_CTRL_CMD_T Enum of dcl.h*/
119/*DCL_CTRL_DATA_T Define the Control data structure for each module's command*/
120typedef enum
121{
122 WDT_CMD_ENABLE , /*to enable/disable WDT*/
123 WDT_CMD_SET_EXT_POL, /*to set ploarity of external pin when WDT expired */
124 WDT_CMD_SET_EXT_RESET, /*to generate an external watchdog reset signal when WDT expired*/
125 WDT_CMD_SET_VALUE, /*to set WDT count value*/
126 WDT_CMD_RESTART, /*to restart counter*/
127 WDT_CMD_DRV_RESET, /*to reset device*/
128 WDT_CMD_ABN_RESET, /*to reset device with abnormal flag set to indicate it is a abnormal reset*/
129 WDT_CMD_IRQ, /*to generate interrupt instead of resetting device*/
130 WDT_CMD_IRQ_AUX,
131 WDT_CMD_GET_RSTINTERVAL,
132 WDT_CMD_GET_RSTINTERVAL_AUX,
133 WDT_CMD_ENABLE_DEBUG,
134 WDT_CMD_CLR_CHECK,
135 WDT_CMD_SET_CHECK,
136 WDT_CMD_CLR_KICK,
137 WDT_CMD_SET_KICK,
138}DCL_CTRL_CMD_T;
139#else
140#define WDT_CMDS \
141 WDT_CMD_ENABLE , \
142 WDT_CMD_SET_EXT_POL, \
143 WDT_CMD_SET_EXT_RESET, \
144 WDT_CMD_SET_VALUE, \
145 WDT_CMD_RESTART, \
146 WDT_CMD_DRV_RESET, \
147 WDT_CMD_ABN_RESET, \
148 WDT_CMD_IRQ, \
149 WDT_CMD_IRQ_AUX, \
150 WDT_CMD_GET_RSTINTERVAL, \
151 WDT_CMD_GET_RSTINTERVAL_AUX, \
152 WDT_CMD_ENABLE_DEBUG, \
153 WDT_CMD_CLR_CHECK, \
154 WDT_CMD_SET_CHECK, \
155 WDT_CMD_CLR_KICK, \
156 WDT_CMD_SET_KICK,
157#endif
158/*******************************************************************************
159 * DCL_CTRL_DATA_T: Define the Control data structure for each module's command
160 *******************************************************************************/
161 typedef struct
162 {
163 DCL_UINT32 rstInterval;
164 }WDT_CTRL_GET_RSTINTERVAL_T;
165
166/* For WDT_CMD_ENABLE command. */
167typedef struct
168{
169 DCL_BOOL fgEnable; // TRUE: Enable WDT, FALSE: Disable WDT
170} WDT_CTRL_ENABLE_T;
171/* For WDT_CMD_SET_EXT_POL command. */
172typedef struct
173{
174 DCL_BOOL fgIOHigh; // TRUE: IO high, FALSE: IO low
175} WDT_CTRL_SET_EXT_POL_T;
176/* For WDT_CMD_SET_EXT_RESET command. */
177typedef struct
178{
179 DCL_BOOL fgEnable; // TRUE: Generate reset signal, FALSE: Do NOT generate reset signal
180} WDT_CTRL_SET_EXT_RESET_T;
181/* For WDT_CMD_SET_VALUE command. */
182typedef struct
183{
184 DCL_UINT16 u2Value; // Set WDT count down value, the unit is 15.6ms
185} WDT_CTRL_SET_VALUE_T;
186/* For WDT_CMD_RESTART command. */
187// WDT_CMD_RESTART does NOT need parameters
188/* For WDT_CMD_DRV_RESET command. */
189// WDT_CMD_DRV_RESET does NOT need parameters
190/* For WDT_CMD_ABN_RESET command. */
191// WDT_CMD_ABN_RESET does NOT need parameters
192/* For WDT_CMD_IRQ command. */
193typedef struct
194{
195 DCL_BOOL fgEnable; // TRUE: Enable interrupt instread of generating reset, FALSE: Do NOT enable interrupt
196} WDT_CTRL_IRQ_T;
197/*For WDT_CMD_ENABLE_DEBUG command*/
198typedef struct
199{
200 DCL_BOOL fgEnable; //enable or disable debug
201}WDT_CTRL_DEBUG_T;
202
203#ifdef __BUILD_DOM__
204/*The GPIO command prarmeter data structure for each command. that's enum in in DCL_CTRL_DATA_T*/
205typedef struct
206{
207 WDT_CTRL_ENABLE_T rWDTEnable; /*data structure for WDT_CMD_ENABLE control command */
208 WDT_CTRL_SET_EXT_POL_T rWDTSetExtPol; /*data structure for WDT_CMD_SET_EXT_POL control command */
209 WDT_CTRL_SET_EXT_RESET_T rWDTSetExtReset; /*data structure for WDT_CMD_SET_EXT_RESET control command */
210 WDT_CTRL_SET_VALUE_T rWDTSetValue; /*data structure for WDT_CMD_SET_VALUE control command */
211 WDT_CTRL_IRQ_T rWDTIRQ; /*data structure for WDT_CMD_IRQ control command */
212 WDT_CTRL_DEBUG_T rWDTDebug; /*data structure for WDT_CMD_ENABLE_DEBUG control command */
213}DCL_CTRL_DATA_T;
214#else
215#define WDT_CTRLS \
216 WDT_CTRL_ENABLE_T rWDTEnable; \
217 WDT_CTRL_SET_EXT_POL_T rWDTSetExtPol; \
218 WDT_CTRL_SET_EXT_RESET_T rWDTSetExtReset; \
219 WDT_CTRL_SET_VALUE_T rWDTSetValue; \
220 WDT_CTRL_IRQ_T rWDTIRQ; \
221 WDT_CTRL_DEBUG_T rWDTDebug; \
222 WDT_CTRL_GET_RSTINTERVAL_T rRstValue;
223#endif
224
225#endif // #ifndef __DCL_I2C_H_STRUCT__
226#endif // #ifdef DCL_DEFINITION_STRUCT
227
228
229#ifdef DCL_DEFINITION_PROTOTYPE
230#ifndef __DCL_WDT_H_PROTOTYPE__
231#define __DCL_WDT_H_PROTOTYPE__
232
233/*************************************************************************
234* FUNCTION
235* DclWDT_Initialize
236*
237* DESCRIPTION
238* This function is to initialize WDT module
239*
240* PARAMETERS
241* None
242*
243* RETURN VALUES
244* STATUS_OK
245*
246*************************************************************************/
247extern DCL_STATUS DclWDT_Initialize(void);
248/*************************************************************************
249* FUNCTION
250* DclWDT_Open
251*
252* DESCRIPTION
253* This function is to open the WDT module and return a handle
254*
255* PARAMETERS
256* dev: only valid for DCL_WDT
257* flags: no sepcial flags is needed. Please use FLAGS_NONE
258*
259* RETURN VALUES
260* DCL_HANDLE_INVALID: Open failed.
261* other value: a valid handle
262*
263*************************************************************************/
264extern DCL_HANDLE DclWDT_Open(DCL_DEV dev, DCL_FLAGS flags);
265/*************************************************************************
266* FUNCTION
267* DclWDT_ReadData
268*
269* DESCRIPTION
270* This function is not supported for the WDT module now.
271*
272* PARAMETERS
273* N/A
274*
275* RETURN VALUES
276* STATUS_UNSUPPORTED
277*
278*************************************************************************/
279extern DCL_STATUS DclWDT_ReadData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options);
280/*************************************************************************
281* FUNCTION
282* DclWDT_WriteData
283*
284* DESCRIPTION
285* This function is not supported for the WDT module now.
286*
287* PARAMETERS
288* N/A
289*
290* RETURN VALUES
291* STATUS_UNSUPPORTED
292*
293*************************************************************************/
294extern DCL_STATUS DclWDT_WriteData(DCL_HANDLE handle, DCL_BUFF *buff, DCL_BUFF_LEN buf_len, DCL_OPTIONS options);
295/*************************************************************************
296* FUNCTION
297* DclWDT_Configure
298*
299* DESCRIPTION
300* This function is not supported for the WDT module now.
301*
302* PARAMETERS
303* N/A
304*
305* RETURN VALUES
306* STATUS_UNSUPPORTED
307*
308*************************************************************************/
309extern DCL_STATUS DclWDT_Configure(DCL_HANDLE handle, DCL_CONFIGURE_T *configure);
310/*************************************************************************
311* FUNCTION
312* DclWDT_RegisterCallback
313*
314* DESCRIPTION
315* This function is to set callback function for the WDT module.
316*
317* PARAMETERS
318* handle: the returned handle value of DclWDT_Open
319* event: Supported events:
320* EVENT_WDT_TIMEOUT: Watch dog time out interrupt
321* callback: the callback function for registered events
322*
323* RETURN VALUES
324* STATUS_OK: Successfully register the callback function.
325* STATUS_INVALID_DCL_HANDLE: It's a invalid handle.
326* STATUS_NOT_OPENED: The module has not been opened.
327* STATUS_INVALID_EVENT: The event parameter is invalid.
328*
329*************************************************************************/
330extern DCL_STATUS DclWDT_RegisterCallback(DCL_HANDLE handle, DCL_EVENT event, PFN_DCL_CALLBACK callback);
331/*************************************************************************
332* FUNCTION
333* DclWDT_Control
334*
335* DESCRIPTION
336* This function is to send command to control the WDT module.
337*
338* PARAMETERS
339* handle: The handle value returned from DclWDT_Open
340* cmd: a control command for WDT module
341* 1. WDT_CMD_ENABLE: to enable/disable WDT
342* 2. WDT_CMD_SET_EXT_POL: to set ploarity of external pin when WDT expired
343* 3. WDT_CMD_SET_EXT_RESET: to generate an external watchdog reset signal when WDT expired
344* 4. WDT_CMD_SET_VALUE: to set WDT count value
345* 5 WDT_CMD_RESTART: to restart counter
346* 6. WDT_CMD_DRV_RESET: to reset device
347* 7. WDT_CMD_ABN_RESET: to reset device with abnormal flag set to indicate it is a abnormal reset
348* 8. WDT_CMD_IRQ: to generate interrupt instead of reseting device
349* data: The data of the control command
350* 1. WDT_CMD_ENABLE: pointer to a WDT_CTRL_ENABLE_T structure
351* 2. WDT_CMD_SET_EXT_POL: pointer to a WDT_CTRL_SET_EXT_POL_T structure
352* 3. WDT_CMD_SET_EXT_RESET: pointer to a WDT_CTRL_SET_EXT_RESET_T structure
353* 4. WDT_CMD_SET_VALUE: pointer to a WDT_CTRL_SET_VALUE_T structure
354* 5 WDT_CMD_RESTART: A null pointer
355* 6. WDT_CMD_DRV_RESET: A null pointer
356* 7. WDT_CMD_ABN_RESET: A null pointer
357* 8. WDT_CMD_IRQ: pointer to a WDT_CTRL_IRQ_T structure
358*
359* RETURN VALUES
360* STATUS_OK: command is executed successfully.
361* STATUS_FAIL: command is failed.
362* STATUS_INVALID_CMD: It's a invalid command.
363*
364*************************************************************************/
365extern DCL_STATUS DclWDT_Control(DCL_HANDLE handle, DCL_CTRL_CMD cmd, DCL_CTRL_DATA_T *data);
366/*************************************************************************
367* FUNCTION
368* DclWDT_Close
369*
370* DESCRIPTION
371* This function is to close the WDT module.
372*
373* PARAMETERS
374* handle: the returned handle value of DclWDT_Open
375*
376* RETURNS
377* STATUS_OK
378*
379*************************************************************************/
380extern DCL_STATUS DclWDT_Close(DCL_HANDLE handle);
381
382
383#endif // #ifndef __DCL_WDT_H_PROTOTYPE__
384#endif // #ifdef DCL_DEFINITION_PROTOTYPE
385
386
387
388
389
390