]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/include/xwdtps.h
Add in the CORTEX_A53_64-bit_UltraScale_MPSoC demo application (a demo has been inclu...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / include / xwdtps.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 2015 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /****************************************************************************/
33 /**
34 *
35 * @file xwdtps.h
36 *
37 * The Xilinx watchdog timer driver supports the Xilinx watchdog timer hardware.
38 *
39 * The Xilinx watchdog timer (WDT) driver supports the following features:
40 *   - Both Interrupt driven and Polled mode
41 *   - enabling and disabling the watchdog timer
42 *   - restarting the watchdog.
43 *   - initializing the most significant digit of the counter restart value.
44 *   - multiple individually enabling/disabling outputs
45 *
46 * It is the responsibility of the application to provide an interrupt handler
47 * for the watchdog timer and connect it to the interrupt system if interrupt
48 * driven mode is desired.
49 *
50 * If interrupt is enabled, the watchdog timer device generates an interrupt
51 * when the counter reaches zero.
52 *
53 * If the hardware interrupt signal is not connected/enabled, polled mode is the
54 * only option (using IsWdtExpired) for the watchdog.
55 *
56 * The outputs from the WDT are individually enabled/disabled using
57 * _EnableOutput()/_DisableOutput(). The clock divisor ratio and initial restart
58 * value of the count is configurable using _SetControlValues().
59 *
60 * The reset condition of the hardware has the maximum initial count in the
61 * Counter Reset Value (CRV) and the WDT is disabled with the reset enable
62 * enabled and the reset length set to 32 clocks. i.e.
63 * <pre>
64 *     register ZMR = 0x1C2
65 *     register CCR = 0x3FC
66 * </pre>
67 *
68 * This driver is intended to be RTOS and processor independent. It works with
69 * physical addresses only.  Any needs for dynamic memory management, threads
70 * or thread mutual exclusion, virtual memory, or cache control must be
71 * satisfied by the layer above this driver.
72 *
73 * <pre>
74 * MODIFICATION HISTORY:
75 *
76 * Ver   Who    Date     Changes
77 * ----- ------ -------- -----------------------------------------------
78 * 1.00a ecm/jz 01/15/10 First release
79 * 1.01a asa    02/15/12 Added tcl file to generate xparameters
80 * 1.02a  sg    07/15/12 Removed code/APIs related to  External Signal
81 *                                               Length functionality for CR 658287
82 *                                               Removed APIs XWdtPs_SetExternalSignalLength,
83 *                                               XWdtPs_GetExternalSignalLength
84 *                                               Modified the Self Test to use the Reset Length mask
85 *                                               for CR 658287
86 * 3.0   pkp        12/09/14 Added support for Zynq Ultrascale Mp.Also
87 *                       modified code for MISRA-C:2012 compliance.
88 * </pre>
89 *
90 ******************************************************************************/
91 #ifndef XWDTPS_H                /* prevent circular inclusions */
92 #define XWDTPS_H                /* by using protection macros */
93
94 /***************************** Include Files *********************************/
95 #include "xil_types.h"
96 #include "xil_assert.h"
97 #include "xstatus.h"
98 #include "xwdtps_hw.h"
99
100 #ifdef __cplusplus
101 extern "C" {
102 #endif
103
104 /************************** Constant Definitions *****************************/
105
106 /*
107  * Choices for output selections for the device, used in
108  * XWdtPs_EnableOutput()/XWdtPs_DisableOutput() functions
109  */
110 #define XWDTPS_RESET_SIGNAL     0x01U   /**< Reset signal request */
111 #define XWDTPS_IRQ_SIGNAL       0x02U   /**< IRQ signal request */
112
113 /*
114  * Control value setting flags, used in
115  * XWdtPs_SetControlValues()/XWdtPs_GetControlValues() functions
116  */
117 #define XWDTPS_CLK_PRESCALE             0x01U   /**< Clock Prescale request */
118 #define XWDTPS_COUNTER_RESET    0x02U   /**< Counter Reset request */
119
120 /**************************** Type Definitions *******************************/
121
122 /**
123  * This typedef contains configuration information for the device.
124  */
125 typedef struct {
126         u16 DeviceId;           /**< Unique ID of device */
127         u32 BaseAddress;        /**< Base address of the device */
128 } XWdtPs_Config;
129
130
131 /**
132  * The XWdtPs driver instance data. The user is required to allocate a
133  * variable of this type for every watchdog/timer device in the system.
134  * A pointer to a variable of this type is then passed to the driver API
135  * functions.
136  */
137 typedef struct {
138         XWdtPs_Config Config;   /**< Hardware Configuration */
139         u32 IsReady;            /**< Device is initialized and ready */
140         u32 IsStarted;          /**< Device watchdog timer is running */
141 } XWdtPs;
142
143 /***************** Macros (Inline Functions) Definitions *********************/
144 /****************************************************************************/
145 /**
146 *
147 * Check if the watchdog timer has expired. This function is used for polled
148 * mode and it is also used to check if the last reset was caused by the
149 * watchdog timer.
150 *
151 * @param        InstancePtr is a pointer to the XWdtPs instance.
152 *
153 * @return
154 *               - TRUE if the watchdog has expired.
155 *               - FALSE if the watchdog has not expired.
156 *
157 * @note         C-style signature:
158 *               int XWdtPs_IsWdtExpired(XWdtPs *InstancePtr)
159 *
160 ******************************************************************************/
161 #define XWdtPs_IsWdtExpired(InstancePtr)                                  \
162 ((XWdtPs_ReadReg((InstancePtr)->Config.BaseAddress, XWDTPS_SR_OFFSET) & \
163    XWDTPS_SR_WDZ_MASK) == XWDTPS_SR_WDZ_MASK)
164
165
166 /****************************************************************************/
167 /**
168 *
169 * Restart the watchdog timer. An application needs to call this function
170 * periodically to keep the timer from asserting the enabled output.
171 *
172 * @param        InstancePtr is a pointer to the XWdtPs instance.
173 *
174 * @return       None.
175 *
176 * @note         C-style signature:
177 *               void XWdtPs_RestartWdt(XWdtPs *InstancePtr)
178 *
179 ******************************************************************************/
180 #define XWdtPs_RestartWdt(InstancePtr)                                  \
181         XWdtPs_WriteReg((InstancePtr)->Config.BaseAddress,              \
182                 XWDTPS_RESTART_OFFSET, XWDTPS_RESTART_KEY_VAL)
183
184 /************************** Function Prototypes ******************************/
185
186 /*
187  * Lookup configuration in xwdtps_sinit.c.
188  */
189 XWdtPs_Config *XWdtPs_LookupConfig(u16 DeviceId);
190
191 /*
192  * Interface functions in xwdtps.c
193  */
194 s32 XWdtPs_CfgInitialize(XWdtPs *InstancePtr,
195                         XWdtPs_Config *ConfigPtr, u32 EffectiveAddress);
196
197 void XWdtPs_Start(XWdtPs *InstancePtr);
198
199 void XWdtPs_Stop(XWdtPs *InstancePtr);
200
201 void XWdtPs_EnableOutput(XWdtPs *InstancePtr, u8 Signal);
202
203 void XWdtPs_DisableOutput(XWdtPs *InstancePtr, u8 Signal);
204
205 u32 XWdtPs_GetControlValue(XWdtPs *InstancePtr, u8 Control);
206
207 void XWdtPs_SetControlValue(XWdtPs *InstancePtr, u8 Control, u32 Value);
208
209 /*
210  * Self-test function in xwdttb_selftest.c.
211  */
212 s32 XWdtPs_SelfTest(XWdtPs *InstancePtr);
213
214
215 #ifdef __cplusplus
216 }
217 #endif
218
219 #endif /* end of protection macro */