]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/wdtps_v3_0/src/xwdtps.h
Update the Xilinx UltraScale+ 64-bit demo to use the hardware definition and BSP...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / wdtps_v3_0 / src / 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 * @addtogroup wdtps_v3_0
37 * @{
38 * @details
39 *
40 * The Xilinx watchdog timer driver supports the Xilinx watchdog timer hardware.
41 *
42 * The Xilinx watchdog timer (WDT) driver supports the following features:
43 *   - Both Interrupt driven and Polled mode
44 *   - enabling and disabling the watchdog timer
45 *   - restarting the watchdog.
46 *   - initializing the most significant digit of the counter restart value.
47 *   - multiple individually enabling/disabling outputs
48 *
49 * It is the responsibility of the application to provide an interrupt handler
50 * for the watchdog timer and connect it to the interrupt system if interrupt
51 * driven mode is desired.
52 *
53 * If interrupt is enabled, the watchdog timer device generates an interrupt
54 * when the counter reaches zero.
55 *
56 * If the hardware interrupt signal is not connected/enabled, polled mode is the
57 * only option (using IsWdtExpired) for the watchdog.
58 *
59 * The outputs from the WDT are individually enabled/disabled using
60 * _EnableOutput()/_DisableOutput(). The clock divisor ratio and initial restart
61 * value of the count is configurable using _SetControlValues().
62 *
63 * The reset condition of the hardware has the maximum initial count in the
64 * Counter Reset Value (CRV) and the WDT is disabled with the reset enable
65 * enabled and the reset length set to 32 clocks. i.e.
66 * <pre>
67 *     register ZMR = 0x1C2
68 *     register CCR = 0x3FC
69 * </pre>
70 *
71 * This driver is intended to be RTOS and processor independent. It works with
72 * physical addresses only.  Any needs for dynamic memory management, threads
73 * or thread mutual exclusion, virtual memory, or cache control must be
74 * satisfied by the layer above this driver.
75 *
76 * <pre>
77 * MODIFICATION HISTORY:
78 *
79 * Ver   Who    Date     Changes
80 * ----- ------ -------- -----------------------------------------------
81 * 1.00a ecm/jz 01/15/10 First release
82 * 1.01a asa    02/15/12 Added tcl file to generate xparameters
83 * 1.02a  sg    07/15/12 Removed code/APIs related to  External Signal
84 *                                               Length functionality for CR 658287
85 *                                               Removed APIs XWdtPs_SetExternalSignalLength,
86 *                                               XWdtPs_GetExternalSignalLength
87 *                                               Modified the Self Test to use the Reset Length mask
88 *                                               for CR 658287
89 * 3.0   pkp        12/09/14 Added support for Zynq Ultrascale Mp.Also
90 *                       modified code for MISRA-C:2012 compliance.
91 * </pre>
92 *
93 ******************************************************************************/
94 #ifndef XWDTPS_H                /* prevent circular inclusions */
95 #define XWDTPS_H                /* by using protection macros */
96
97 /***************************** Include Files *********************************/
98 #include "xil_types.h"
99 #include "xil_assert.h"
100 #include "xstatus.h"
101 #include "xwdtps_hw.h"
102
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106
107 /************************** Constant Definitions *****************************/
108
109 /*
110  * Choices for output selections for the device, used in
111  * XWdtPs_EnableOutput()/XWdtPs_DisableOutput() functions
112  */
113 #define XWDTPS_RESET_SIGNAL     0x01U   /**< Reset signal request */
114 #define XWDTPS_IRQ_SIGNAL       0x02U   /**< IRQ signal request */
115
116 /*
117  * Control value setting flags, used in
118  * XWdtPs_SetControlValues()/XWdtPs_GetControlValues() functions
119  */
120 #define XWDTPS_CLK_PRESCALE             0x01U   /**< Clock Prescale request */
121 #define XWDTPS_COUNTER_RESET    0x02U   /**< Counter Reset request */
122
123 /**************************** Type Definitions *******************************/
124
125 /**
126  * This typedef contains configuration information for the device.
127  */
128 typedef struct {
129         u16 DeviceId;           /**< Unique ID of device */
130         u32 BaseAddress;        /**< Base address of the device */
131 } XWdtPs_Config;
132
133
134 /**
135  * The XWdtPs driver instance data. The user is required to allocate a
136  * variable of this type for every watchdog/timer device in the system.
137  * A pointer to a variable of this type is then passed to the driver API
138  * functions.
139  */
140 typedef struct {
141         XWdtPs_Config Config;   /**< Hardware Configuration */
142         u32 IsReady;            /**< Device is initialized and ready */
143         u32 IsStarted;          /**< Device watchdog timer is running */
144 } XWdtPs;
145
146 /***************** Macros (Inline Functions) Definitions *********************/
147 /****************************************************************************/
148 /**
149 *
150 * Check if the watchdog timer has expired. This function is used for polled
151 * mode and it is also used to check if the last reset was caused by the
152 * watchdog timer.
153 *
154 * @param        InstancePtr is a pointer to the XWdtPs instance.
155 *
156 * @return
157 *               - TRUE if the watchdog has expired.
158 *               - FALSE if the watchdog has not expired.
159 *
160 * @note         C-style signature:
161 *               int XWdtPs_IsWdtExpired(XWdtPs *InstancePtr)
162 *
163 ******************************************************************************/
164 #define XWdtPs_IsWdtExpired(InstancePtr)                                  \
165 ((XWdtPs_ReadReg((InstancePtr)->Config.BaseAddress, XWDTPS_SR_OFFSET) & \
166    XWDTPS_SR_WDZ_MASK) == XWDTPS_SR_WDZ_MASK)
167
168
169 /****************************************************************************/
170 /**
171 *
172 * Restart the watchdog timer. An application needs to call this function
173 * periodically to keep the timer from asserting the enabled output.
174 *
175 * @param        InstancePtr is a pointer to the XWdtPs instance.
176 *
177 * @return       None.
178 *
179 * @note         C-style signature:
180 *               void XWdtPs_RestartWdt(XWdtPs *InstancePtr)
181 *
182 ******************************************************************************/
183 #define XWdtPs_RestartWdt(InstancePtr)                                  \
184         XWdtPs_WriteReg((InstancePtr)->Config.BaseAddress,              \
185                 XWDTPS_RESTART_OFFSET, XWDTPS_RESTART_KEY_VAL)
186
187 /************************** Function Prototypes ******************************/
188
189 /*
190  * Lookup configuration in xwdtps_sinit.c.
191  */
192 XWdtPs_Config *XWdtPs_LookupConfig(u16 DeviceId);
193
194 /*
195  * Interface functions in xwdtps.c
196  */
197 s32 XWdtPs_CfgInitialize(XWdtPs *InstancePtr,
198                         XWdtPs_Config *ConfigPtr, u32 EffectiveAddress);
199
200 void XWdtPs_Start(XWdtPs *InstancePtr);
201
202 void XWdtPs_Stop(XWdtPs *InstancePtr);
203
204 void XWdtPs_EnableOutput(XWdtPs *InstancePtr, u8 Signal);
205
206 void XWdtPs_DisableOutput(XWdtPs *InstancePtr, u8 Signal);
207
208 u32 XWdtPs_GetControlValue(XWdtPs *InstancePtr, u8 Control);
209
210 void XWdtPs_SetControlValue(XWdtPs *InstancePtr, u8 Control, u32 Value);
211
212 /*
213  * Self-test function in xwdttb_selftest.c.
214  */
215 s32 XWdtPs_SelfTest(XWdtPs *InstancePtr);
216
217
218 #ifdef __cplusplus
219 }
220 #endif
221
222 #endif /* end of protection macro */
223 /** @} */