arm: sc8830: remove build warnings
[profile/mobile/platform/kernel/u-boot-tm1.git] / arch / arm / cpu / armv7 / sc8830 / watchdog_hal.c
1 /******************************************************************************
2  ** File Name:      watchdog_hal.c                                                 *
3  ** Author:         Jimmy.Jia                                                 *
4  ** DATE:           10/28/2004                                                *
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  ******************************************************************************
10
11  ******************************************************************************
12  **                        Edit History                                       *
13  ** ------------------------------------------------------------------------- *
14  ** DATE           NAME             DESCRIPTION                               *
15  ** 04/02/2002     Jimmy.Jia        Create.                                   *
16 **  01/03/2008     Yi.Qiu        For SC6600L                                  *
17  ******************************************************************************/
18
19 /**---------------------------------------------------------------------------*
20  **                         Dependencies                                      *
21  **---------------------------------------------------------------------------*/
22 #include <common.h>
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>
30
31 #define  WDG_TRACE  printf
32 /**---------------------------------------------------------------------------*
33  **                      Function Declaration                                 *
34  **---------------------------------------------------------------------------*/
35
36 /*****************************************************************************/
37 //  Description:    This function disable WDG timer
38 //  Author:         Jimmy.Jia
39 //  Note:           no rtc_clk to drive the counter
40 //
41 /*****************************************************************************/
42 PUBLIC void WDG_TimerStop
43 (
44     void
45 )
46 {
47     WDG_CONFIG_T config;
48
49     WDG_TRACE ("Watch Dog Trace: WDG_TimerStop");
50     WDG_PHY_INT_CLR();
51
52     config.state    = WDG_TIMER_STATE_STOP  ;
53     config.mode     = WDG_TIMEOUT_MODE_RESET;
54     config.val      = WDG_MAX_COUNT;
55
56     WDG_PHY_CONFIG (&config);
57
58     return;
59 }
60
61 /*****************************************************************************/
62 //  Description:    This function initialize and setup timer with given value
63 //  Author:         Jimmy.Jia
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
68 (
69     uint32 init_val
70 )
71 {
72     WDG_CONFIG_T config;
73
74     WDG_TRACE ("Watch Dog Trace: WDG_TimerStart");
75
76     config.state    = WDG_TIMER_STATE_START ;
77     config.mode     = WDG_TIMEOUT_MODE_RESET;
78     config.val      = init_val;
79
80     WDG_PHY_CONFIG (&config);
81
82 }
83
84 /*****************************************************************************/
85 //  Description:    This function handle WatchDog Interrupt
86 //  Author:         Binggo Zhou
87 //  Note:
88 /*****************************************************************************/
89 PUBLIC void WDG_TimerHandler (uint32 int_num)
90 {
91     WDG_PHY_INT_CLR();
92 }
93
94 /*****************************************************************************/
95 //  Description:    This function init WatchDog
96 //  Author:         Binggo Zhou
97 //  Note:
98 /*****************************************************************************/
99 PUBLIC void WDG_TimerInit (void)
100 {
101     WDG_CONFIG_T config;
102
103     WDG_TRACE ("Watch Dog Trace: WDG_TimerInit");
104
105     config.state    = WDG_TIMER_STATE_START ;
106     config.mode     = WDG_TIMEOUT_MODE_RESET;
107     config.val      = WDG_INIT_COUNT;
108
109     WDG_PHY_CONFIG (&config);
110 }
111
112 /*****************************************************************************/
113 //  Description:    This function Reset MCU
114 //  Author:         Younger.Yang
115 //  Note:
116 /*****************************************************************************/
117 PUBLIC void WDG_ResetMCU (void)
118 {
119     WDG_CONFIG_T config;
120
121     WDG_TRACE ("Watch Dog Trace: WDG_ResetMCU");
122     config.state    = WDG_TIMER_STATE_START ;
123     config.mode     = WDG_TIMEOUT_MODE_RESET;
124     config.val      = 0x50;
125
126     WDG_PHY_CONFIG (&config);
127 }
128
129 /*****************************************************************************/
130 //  Description:    This function Load WatchDog Timer Value
131 //  Author:         Binggo Zhou
132 //  Note:
133 /*****************************************************************************/
134 PUBLIC void WDG_TimerLoad (uint32 time_ms)
135 {
136     WDG_CONFIG_T config;
137
138     WDG_TRACE ("Watch Dog Trace: WDG_TimerLoad %lu", time_ms);
139
140     config.state    = WDG_TIMER_STATE_KEEP  ;
141     config.mode     = WDG_TIMEOUT_MODE_KEEP ;
142     config.val      = (time_ms * 1000) / 30;
143
144     WDG_PHY_CONFIG (&config);
145 }
146
147 PUBLIC uint32 WDG_PHY_RST_INT_ON(void)
148 {
149         uint32 ret = 0;
150         uint32 val = 0;
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;
154         WDG_PHY_INT_CLR();
155         return ret;
156 }