1 /******************************************************************************
2 ** File Name: watchdog_hal.c *
5 ** Copyright: 2004 Spreadtrum, Incoporated. All Rights Reserved. *
6 ** Description: This file defines the basic operation interfaces of *
7 ** serrial device. It manages create, send, receive *
8 ** interface of serrial port. *
9 ******************************************************************************
11 ******************************************************************************
13 ** ------------------------------------------------------------------------- *
14 ** DATE NAME DESCRIPTION *
15 ** 04/02/2002 Jimmy.Jia Create. *
16 ** 01/03/2008 Yi.Qiu For SC6600L *
17 ******************************************************************************/
19 /**---------------------------------------------------------------------------*
21 **---------------------------------------------------------------------------*/
22 #include <asm/arch/sci_types.h>
23 #include <asm/arch/sc_reg.h>
24 #include <asm/arch/os_api.h>
25 #include <asm/arch/wdg_drvapi.h>
26 //#include "fiq_drvapi.h"
27 #include <asm/arch/watchdog_phy.h>
28 #include <asm/arch/watchdog_reg_v3.h>
30 #define WDG_TRACE printf
31 /**---------------------------------------------------------------------------*
32 ** Function Declaration *
33 **---------------------------------------------------------------------------*/
35 /*****************************************************************************/
36 // Description: This function disable WDG timer
38 // Note: no rtc_clk to drive the counter
40 /*****************************************************************************/
41 PUBLIC void WDG_TimerStop
49 WDG_TRACE ("Watch Dog Trace: WDG_TimerStop");
52 config.state = WDG_TIMER_STATE_STOP ;
53 config.mode = WDG_TIMEOUT_MODE_RESET;
54 config.val = WDG_MAX_COUNT;
56 ret = WDG_PHY_CONFIG (&config);
61 /*****************************************************************************/
62 // Description: This function initialize and setup timer with given value
64 // Note: rtc_clk drive the counter
65 // load regiter is 32 bits wide so that don't check if param's valid
66 /*****************************************************************************/
67 PUBLIC void WDG_TimerStart
75 WDG_TRACE ("Watch Dog Trace: WDG_TimerStart");
77 config.state = WDG_TIMER_STATE_START ;
78 config.mode = WDG_TIMEOUT_MODE_RESET;
79 config.val = init_val;
81 ret = WDG_PHY_CONFIG (&config);
85 /*****************************************************************************/
86 // Description: This function handle WatchDog Interrupt
87 // Author: Binggo Zhou
89 /*****************************************************************************/
90 PUBLIC void WDG_TimerHandler (uint32 int_num)
95 /*****************************************************************************/
96 // Description: This function init WatchDog
97 // Author: Binggo Zhou
99 /*****************************************************************************/
100 PUBLIC void WDG_TimerInit (void)
106 WDG_TRACE ("Watch Dog Trace: WDG_TimerInit");
108 config.state = WDG_TIMER_STATE_START ;
109 config.mode = WDG_TIMEOUT_MODE_RESET;
110 config.val = WDG_INIT_COUNT;
112 ret = WDG_PHY_CONFIG (&config);
115 /*****************************************************************************/
116 // Description: This function Reset MCU
117 // Author: Younger.Yang
119 /*****************************************************************************/
120 PUBLIC void WDG_ResetMCU (void)
125 WDG_TRACE ("Watch Dog Trace: WDG_ResetMCU");
126 config.state = WDG_TIMER_STATE_START ;
127 config.mode = WDG_TIMEOUT_MODE_RESET;
130 ret = WDG_PHY_CONFIG (&config);
133 /*****************************************************************************/
134 // Description: This function Load WatchDog Timer Value
135 // Author: Binggo Zhou
137 /*****************************************************************************/
138 PUBLIC void WDG_TimerLoad (uint32 time_ms)
143 WDG_TRACE ("Watch Dog Trace: WDG_TimerLoad %d", time_ms);
145 config.state = WDG_TIMER_STATE_KEEP ;
146 config.mode = WDG_TIMEOUT_MODE_KEEP ;
147 config.val = (time_ms * 1000) / 30;
149 ret = WDG_PHY_CONFIG (&config);
152 PUBLIC uint32 WDG_PHY_RST_INT_ON(void)
156 val = WDG_PHY_RST_RAW_INT();
157 printf("hw watchdog int raw status 0x%x\n", val);
158 ret = val & WDG_INT_RST_BIT;