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>
30 /**---------------------------------------------------------------------------*
31 ** Function Declaration *
32 **---------------------------------------------------------------------------*/
34 /*****************************************************************************/
35 // Description: This function disable WDG timer
37 // Note: no rtc_clk to drive the counter
39 /*****************************************************************************/
40 PUBLIC void WDG_TimerStop
48 WDG_TRACE ("Watch Dog Trace: WDG_TimerStop");
51 config.state = WDG_TIMER_STATE_STOP ;
52 config.mode = WDG_TIMEOUT_MODE_RESET;
53 config.val = WDG_MAX_COUNT;
55 ret = WDG_PHY_CONFIG (&config);
60 /*****************************************************************************/
61 // Description: This function initialize and setup timer with given value
63 // Note: rtc_clk drive the counter
64 // load regiter is 32 bits wide so that don't check if param's valid
65 /*****************************************************************************/
66 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_KEEP;
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 config.state = WDG_TIMER_STATE_START ;
107 config.mode = WDG_TIMEOUT_MODE_RESET;
108 config.val = WDG_INIT_COUNT;
109 ret = WDG_PHY_CONFIG (&config);
110 printf("Watch Dog configuration is finished and ");
111 #if 0 //added by mingwei
112 status = FIQ_RegHandler (TB_WDG_INT, WDG_TimerHandler);
113 SCI_PASSERT ( (FIQ_SUCCESS == status || FIQ_ISR_ASSIGNED == status),
114 ("%s, %d, fiq regist status: %d", __MODULE__, __LINE__, status));
118 /*****************************************************************************/
119 // Description: This function Reset MCU
120 // Author: Younger.Yang
122 /*****************************************************************************/
123 PUBLIC void WDG_ResetMCU (void)
128 config.state = WDG_TIMER_STATE_START ;
129 config.mode = WDG_TIMEOUT_MODE_RESET;
130 config.val = 20000/*0x50*/;
132 ret = WDG_PHY_CONFIG (&config);
133 printf("Wait for watch dog to reset phone!\n");
136 /*****************************************************************************/
137 // Description: This function Load WatchDog Timer Value
138 // Author: Binggo Zhou
140 /*****************************************************************************/
141 PUBLIC void WDG_TimerLoad (uint32 time_ms)
146 WDG_TRACE ("Watch Dog Trace: WDG_TimerLoad %d", time_ms);
148 config.state = WDG_TIMER_STATE_KEEP ;
149 config.mode = WDG_TIMEOUT_MODE_KEEP ;
150 config.val = (time_ms * 1000) / 30;
152 ret = WDG_PHY_CONFIG (&config);