1 /******************************************************************************
3 * Copyright (C) 2015 Xilinx, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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 THE
22 * XILINX CONSORTIUM 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
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.
31 ******************************************************************************/
32 /*****************************************************************************/
36 * @addtogroup rtcpsu_v1_0
39 * This header file contains the identifiers and basic driver functions (or
40 * macros) that can be used to access the device. Other driver functions
41 * are defined in xrtcpsu.h.
44 * MODIFICATION HISTORY:
46 * Ver Who Date Changes
47 * ----- ----- -------- -----------------------------------------------
48 * 1.00a kvn 04/21/15 First release
49 * 1.1 kvn 09/25/15 Modify control register to enable battery
50 * switching when vcc_psaux is not available.
54 ******************************************************************************/
56 #ifndef XRTC_HW_H_ /* prevent circular inclusions */
57 #define XRTC_HW_H_ /* by using protection macros */
63 /***************************** Include Files *********************************/
65 #include "xil_types.h"
66 #include "xil_assert.h"
69 /************************** Constant Definitions *****************************/
74 #define XRTC_BASEADDR 0xFFA60000U
77 * Register: XrtcSetTimeWr
79 #define XRTC_SET_TIME_WR_OFFSET 0x00000000U
80 #define XRTC_SET_TIME_WR_RSTVAL 0x00000000U
82 #define XRTC_SET_TIME_WR_VAL_SHIFT 0U
83 #define XRTC_SET_TIME_WR_VAL_WIDTH 32U
84 #define XRTC_SET_TIME_WR_VAL_MASK 0xffffffffU
85 #define XRTC_SET_TIME_WR_VAL_DEFVAL 0x0U
88 * Register: XrtcSetTimeRd
90 #define XRTC_SET_TIME_RD_OFFSET 0x00000004U
91 #define XRTC_SET_TIME_RD_RSTVAL 0x00000000U
93 #define XRTC_SET_TIME_RD_VAL_SHIFT 0U
94 #define XRTC_SET_TIME_RD_VAL_WIDTH 32U
95 #define XRTC_SET_TIME_RD_VAL_MASK 0xffffffffU
96 #define XRTC_SET_TIME_RD_VAL_DEFVAL 0x0U
99 * Register: XrtcCalibWr
101 #define XRTC_CALIB_WR_OFFSET 0x00000008U
102 #define XRTC_CALIB_WR_RSTVAL 0x00000000U
104 #define XRTC_CALIB_WR_FRACTN_EN_SHIFT 20U
105 #define XRTC_CALIB_WR_FRACTN_EN_WIDTH 1U
106 #define XRTC_CALIB_WR_FRACTN_EN_MASK 0x00100000U
107 #define XRTC_CALIB_WR_FRACTN_EN_DEFVAL 0x0U
109 #define XRTC_CALIB_WR_FRACTN_DATA_SHIFT 16U
110 #define XRTC_CALIB_WR_FRACTN_DATA_WIDTH 4U
111 #define XRTC_CALIB_WR_FRACTN_DATA_MASK 0x000f0000U
112 #define XRTC_CALIB_WR_FRACTN_DATA_DEFVAL 0x0U
114 #define XRTC_CALIB_WR_MAX_TCK_SHIFT 0U
115 #define XRTC_CALIB_WR_MAX_TCK_WIDTH 16U
116 #define XRTC_CALIB_WR_MAX_TCK_MASK 0x0000ffffU
117 #define XRTC_CALIB_WR_MAX_TCK_DEFVAL 0x0U
120 * Register: XrtcCalibRd
122 #define XRTC_CALIB_RD_OFFSET 0x0000000CU
123 #define XRTC_CALIB_RD_RSTVAL 0x00000000U
125 #define XRTC_CALIB_RD_FRACTN_EN_SHIFT 20U
126 #define XRTC_CALIB_RD_FRACTN_EN_WIDTH 1U
127 #define XRTC_CALIB_RD_FRACTN_EN_MASK 0x00100000U
128 #define XRTC_CALIB_RD_FRACTN_EN_DEFVAL 0x0U
130 #define XRTC_CALIB_RD_FRACTN_DATA_SHIFT 16U
131 #define XRTC_CALIB_RD_FRACTN_DATA_WIDTH 4U
132 #define XRTC_CALIB_RD_FRACTN_DATA_MASK 0x000f0000U
133 #define XRTC_CALIB_RD_FRACTN_DATA_DEFVAL 0x0U
135 #define XRTC_CALIB_RD_MAX_TCK_SHIFT 0U
136 #define XRTC_CALIB_RD_MAX_TCK_WIDTH 16U
137 #define XRTC_CALIB_RD_MAX_TCK_MASK 0x0000ffffU
138 #define XRTC_CALIB_RD_MAX_TCK_DEFVAL 0x0U
141 * Register: XrtcCurTime
143 #define XRTC_CUR_TIME_OFFSET 0x00000010U
144 #define XRTC_CUR_TIME_RSTVAL 0x00000000U
146 #define XRTC_CUR_TIME_VAL_SHIFT 0U
147 #define XRTC_CUR_TIME_VAL_WIDTH 32U
148 #define XRTC_CUR_TIME_VAL_MASK 0xffffffffU
149 #define XRTC_CUR_TIME_VAL_DEFVAL 0x0U
152 * Register: XrtcCurTck
154 #define XRTC_CUR_TCK_OFFSET 0x00000014U
155 #define XRTC_CUR_TCK_RSTVAL 0x00000000U
157 #define XRTC_CUR_TCK_VAL_SHIFT 0U
158 #define XRTC_CUR_TCK_VAL_WIDTH 16U
159 #define XRTC_CUR_TCK_VAL_MASK 0x0000ffffU
160 #define XRTC_CUR_TCK_VAL_DEFVAL 0x0U
165 #define XRTC_ALRM_OFFSET 0x00000018U
166 #define XRTC_ALRM_RSTVAL 0x00000000U
168 #define XRTC_ALRM_VAL_SHIFT 0U
169 #define XRTC_ALRM_VAL_WIDTH 32U
170 #define XRTC_ALRM_VAL_MASK 0xffffffffU
171 #define XRTC_ALRM_VAL_DEFVAL 0x0U
174 * Register: XrtcIntSts
176 #define XRTC_INT_STS_OFFSET 0x00000020U
177 #define XRTC_INT_STS_RSTVAL 0x00000000U
179 #define XRTC_INT_STS_ALRM_SHIFT 1U
180 #define XRTC_INT_STS_ALRM_WIDTH 1U
181 #define XRTC_INT_STS_ALRM_MASK 0x00000002U
182 #define XRTC_INT_STS_ALRM_DEFVAL 0x0U
184 #define XRTC_INT_STS_SECS_SHIFT 0U
185 #define XRTC_INT_STS_SECS_WIDTH 1U
186 #define XRTC_INT_STS_SECS_MASK 0x00000001U
187 #define XRTC_INT_STS_SECS_DEFVAL 0x0U
190 * Register: XrtcIntMsk
192 #define XRTC_INT_MSK_OFFSET 0x00000024U
193 #define XRTC_INT_MSK_RSTVAL 0x00000003U
195 #define XRTC_INT_MSK_ALRM_SHIFT 1U
196 #define XRTC_INT_MSK_ALRM_WIDTH 1U
197 #define XRTC_INT_MSK_ALRM_MASK 0x00000002U
198 #define XRTC_INT_MSK_ALRM_DEFVAL 0x1U
200 #define XRTC_INT_MSK_SECS_SHIFT 0U
201 #define XRTC_INT_MSK_SECS_WIDTH 1U
202 #define XRTC_INT_MSK_SECS_MASK 0x00000001U
203 #define XRTC_INT_MSK_SECS_DEFVAL 0x1U
206 * Register: XrtcIntEn
208 #define XRTC_INT_EN_OFFSET 0x00000028U
209 #define XRTC_INT_EN_RSTVAL 0x00000000U
211 #define XRTC_INT_EN_ALRM_SHIFT 1U
212 #define XRTC_INT_EN_ALRM_WIDTH 1U
213 #define XRTC_INT_EN_ALRM_MASK 0x00000002U
214 #define XRTC_INT_EN_ALRM_DEFVAL 0x0U
216 #define XRTC_INT_EN_SECS_SHIFT 0U
217 #define XRTC_INT_EN_SECS_WIDTH 1U
218 #define XRTC_INT_EN_SECS_MASK 0x00000001U
219 #define XRTC_INT_EN_SECS_DEFVAL 0x0U
222 * Register: XrtcIntDis
224 #define XRTC_INT_DIS_OFFSET 0x0000002CU
225 #define XRTC_INT_DIS_RSTVAL 0x00000000U
227 #define XRTC_INT_DIS_ALRM_SHIFT 1U
228 #define XRTC_INT_DIS_ALRM_WIDTH 1U
229 #define XRTC_INT_DIS_ALRM_MASK 0x00000002U
230 #define XRTC_INT_DIS_ALRM_DEFVAL 0x0U
232 #define XRTC_INT_DIS_SECS_SHIFT 0U
233 #define XRTC_INT_DIS_SECS_WIDTH 1U
234 #define XRTC_INT_DIS_SECS_MASK 0x00000001U
235 #define XRTC_INT_DIS_SECS_DEFVAL 0x0U
238 * Register: XrtcAddErr
240 #define XRTC_ADD_ERR_OFFSET 0x00000030U
241 #define XRTC_ADD_ERR_RSTVAL 0x00000000U
243 #define XRTC_ADD_ERR_STS_SHIFT 0U
244 #define XRTC_ADD_ERR_STS_WIDTH 1U
245 #define XRTC_ADD_ERR_STS_MASK 0x00000001U
246 #define XRTC_ADD_ERR_STS_DEFVAL 0x0U
249 * Register: XrtcAddErrIntMsk
251 #define XRTC_ADD_ERR_INT_MSK_OFFSET 0x00000034U
252 #define XRTC_ADD_ERR_INT_MSK_RSTVAL 0x00000001U
254 #define XRTC_ADD_ERR_INT_MSK_SHIFT 0U
255 #define XRTC_ADD_ERR_INT_MSK_WIDTH 1U
256 #define XRTC_ADD_ERR_INT_MSK_MASK 0x00000001U
257 #define XRTC_ADD_ERR_INT_MSK_DEFVAL 0x1U
260 * Register: XrtcAddErrIntEn
262 #define XRTC_ADD_ERR_INT_EN_OFFSET 0x00000038U
263 #define XRTC_ADD_ERR_INT_EN_RSTVAL 0x00000000U
265 #define XRTC_ADD_ERR_INT_EN_MSK_SHIFT 0U
266 #define XRTC_ADD_ERR_INT_EN_MSK_WIDTH 1U
267 #define XRTC_ADD_ERR_INT_EN_MSK_MASK 0x00000001U
268 #define XRTC_ADD_ERR_INT_EN_MSK_DEFVAL 0x0U
271 * Register: XrtcAddErrIntDis
273 #define XRTC_ADD_ERR_INT_DIS_OFFSET 0x0000003CU
274 #define XRTC_ADD_ERR_INT_DIS_RSTVAL 0x00000000U
276 #define XRTC_ADD_ERR_INT_DIS_MSK_SHIFT 0U
277 #define XRTC_ADD_ERR_INT_DIS_MSK_WIDTH 1U
278 #define XRTC_ADD_ERR_INT_DIS_MSK_MASK 0x00000001U
279 #define XRTC_ADD_ERR_INT_DIS_MSK_DEFVAL 0x0U
284 #define XRTC_CTL_OFFSET 0x00000040U
285 #define XRTC_CTL_RSTVAL 0x01000000U
287 #define XRTC_CTL_BATTERY_EN_SHIFT 31U
288 #define XRTC_CTL_BATTERY_EN_WIDTH 1U
289 #define XRTC_CTL_BATTERY_EN_MASK 0x80000000U
290 #define XRTC_CTL_BATTERY_EN_DEFVAL 0x0U
292 #define XRTC_CTL_OSC_SHIFT 24U
293 #define XRTC_CTL_OSC_WIDTH 4U
294 #define XRTC_CTL_OSC_MASK 0x0f000000U
295 #define XRTC_CTL_OSC_DEFVAL 0x1U
297 #define XRTC_CTL_SLVERR_EN_SHIFT 0U
298 #define XRTC_CTL_SLVERR_EN_WIDTH 1U
299 #define XRTC_CTL_SLVERR_EN_MASK 0x00000001U
300 #define XRTC_CTL_SLVERR_EN_DEFVAL 0x0U
303 * Register: XrtcSftyChk
305 #define XRTC_SFTY_CHK_OFFSET 0x00000050U
306 #define XRTC_SFTY_CHK_RSTVAL 0x00000000U
308 #define XRTC_SFTY_CHK_REG_SHIFT 0U
309 #define XRTC_SFTY_CHK_REG_WIDTH 32U
310 #define XRTC_SFTY_CHK_REG_MASK 0xffffffffU
311 #define XRTC_SFTY_CHK_REG_DEFVAL 0x0U
316 #define XRTC_ECO_OFFSET 0x00000060U
317 #define XRTC_ECO_RSTVAL 0x00000000U
319 #define XRTC_ECO_REG_SHIFT 0U
320 #define XRTC_ECO_REG_WIDTH 32U
321 #define XRTC_ECO_REG_MASK 0xffffffffU
322 #define XRTC_ECO_REG_DEFVAL 0x0U
324 /***************** Macros (Inline Functions) Definitions *********************/
326 /****************************************************************************/
329 * This macro reads the given register.
331 * @param RegisterAddr is the register address in the address
332 * space of the RTC device.
334 * @return The 32-bit value of the register
338 *****************************************************************************/
339 #define XRtcPsu_ReadReg(RegisterAddr) Xil_In32(RegisterAddr)
341 /****************************************************************************/
344 * This macro writes the given register.
346 * @param RegisterAddr is the register address in the address
347 * space of the RTC device.
348 * @param Data is the 32-bit value to write to the register.
354 *****************************************************************************/
355 #define XRtcPsu_WriteReg(RegisterAddr, Data) Xil_Out32(RegisterAddr, (u32)(Data))
361 #endif /* XRTC_HW_H_ */