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 **---------------------------------------------------------------------------*/
23 #include <asm/arch/sci_types.h>
24 #include <asm/arch/sc_reg.h>
25 #include <asm/arch/os_api.h>
26 #include <asm/arch/wdg_drvapi.h>
27 //#include "fiq_drvapi.h"
28 #include <asm/arch/watchdog_phy.h>
29 #include <asm/arch/watchdog_reg_v3.h>
31 #define WDG_TRACE printf
32 /**---------------------------------------------------------------------------*
33 ** Function Declaration *
34 **---------------------------------------------------------------------------*/
36 /*****************************************************************************/
37 // Description: This function disable WDG timer
39 // Note: no rtc_clk to drive the counter
41 /*****************************************************************************/
42 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 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
74 WDG_TRACE ("Watch Dog Trace: WDG_TimerStart");
76 config.state = WDG_TIMER_STATE_START ;
77 config.mode = WDG_TIMEOUT_MODE_RESET;
78 config.val = init_val;
80 WDG_PHY_CONFIG (&config);
84 /*****************************************************************************/
85 // Description: This function handle WatchDog Interrupt
86 // Author: Binggo Zhou
88 /*****************************************************************************/
89 PUBLIC void WDG_TimerHandler (uint32 int_num)
94 /*****************************************************************************/
95 // Description: This function init WatchDog
96 // Author: Binggo Zhou
98 /*****************************************************************************/
99 PUBLIC void WDG_TimerInit (void)
103 WDG_TRACE ("Watch Dog Trace: WDG_TimerInit");
105 config.state = WDG_TIMER_STATE_START ;
106 config.mode = WDG_TIMEOUT_MODE_RESET;
107 config.val = WDG_INIT_COUNT;
109 WDG_PHY_CONFIG (&config);
112 /*****************************************************************************/
113 // Description: This function Reset MCU
114 // Author: Younger.Yang
116 /*****************************************************************************/
117 PUBLIC void WDG_ResetMCU (void)
121 WDG_TRACE ("Watch Dog Trace: WDG_ResetMCU");
122 config.state = WDG_TIMER_STATE_START ;
123 config.mode = WDG_TIMEOUT_MODE_RESET;
126 WDG_PHY_CONFIG (&config);
129 /*****************************************************************************/
130 // Description: This function Load WatchDog Timer Value
131 // Author: Binggo Zhou
133 /*****************************************************************************/
134 PUBLIC void WDG_TimerLoad (uint32 time_ms)
138 WDG_TRACE ("Watch Dog Trace: WDG_TimerLoad %lu", time_ms);
140 config.state = WDG_TIMER_STATE_KEEP ;
141 config.mode = WDG_TIMEOUT_MODE_KEEP ;
142 config.val = (time_ms * 1000) / 30;
144 WDG_PHY_CONFIG (&config);
147 PUBLIC uint32 WDG_PHY_RST_INT_ON(void)
151 val = WDG_PHY_RST_RAW_INT();
152 printf("hw watchdog int raw status 0x%lx\n", val);
153 ret = val & WDG_INT_RST_BIT;