]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/sysmonpsu_v1_0/src/xsysmonpsu_intr.c
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 / sysmonpsu_v1_0 / src / xsysmonpsu_intr.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2016 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 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
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 xsysmonpsu_intr.c
36 *
37 * This file contains functions related to SYSMONPSU interrupt handling.
38 *
39 * <pre>
40 * MODIFICATION HISTORY:
41 *
42 * Ver   Who    Date     Changes
43 * ----- -----  -------- -----------------------------------------------
44 * 1.0   kvn    12/15/15 First release
45 * </pre>
46 *
47 ******************************************************************************/
48
49 /***************************** Include Files *********************************/
50
51 #include "xsysmonpsu.h"
52
53 /************************** Constant Definitions *****************************/
54
55 /**************************** Type Definitions *******************************/
56
57 /***************** Macros (Inline Functions) Definitions *********************/
58
59 /************************** Variable Definitions *****************************/
60
61 /************************** Function Prototypes ******************************/
62
63 /************************** Variable Definitions ****************************/
64
65 /****************************************************************************/
66 /**
67 *
68 * This function enables the specified interrupts in the device.
69 *
70 * @param        InstancePtr is a pointer to the XSysMonPsu instance.
71 * @param        Mask is the 64 bit-mask of the interrupts to be enabled.
72 *               Bit positions of 1 will be enabled. Bit positions of 0 will
73 *               keep the previous setting. This mask is formed by OR'ing
74 *               XSYSMONPSU_IER_0_* and XSYSMONPSU_IER_1_* bits defined in
75 *               xsysmonpsu_hw.h.
76 *
77 * @return       None.
78 *
79 * @note         None.
80 *
81 *****************************************************************************/
82 void XSysMonPsu_IntrEnable(XSysMonPsu *InstancePtr, u64 Mask)
83 {
84         u32 RegValue;
85
86         /* Assert the arguments. */
87         Xil_AssertVoid(InstancePtr != NULL);
88         Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
89
90         /* Enable the specified interrupts in the AMS Interrupt Enable Register. */
91         RegValue = XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
92                                         XSYSMONPSU_IER_0_OFFSET);
93         RegValue |= (u32)(Mask & (u64)XSYSMONPSU_IXR_0_MASK);
94         XSysmonPsu_WriteReg(InstancePtr->Config.BaseAddress + XSYSMONPSU_IER_0_OFFSET,
95                           RegValue);
96
97         RegValue = XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
98                                         XSYSMONPSU_IER_1_OFFSET);
99         RegValue |= (u32)((Mask >> XSYSMONPSU_IXR_1_SHIFT) & XSYSMONPSU_IXR_1_MASK);
100         XSysmonPsu_WriteReg(InstancePtr->Config.BaseAddress + XSYSMONPSU_IER_1_OFFSET,
101                           RegValue);
102 }
103
104 /****************************************************************************/
105 /**
106 *
107 * This function disables the specified interrupts in the device.
108 *
109 * @param        InstancePtr is a pointer to the XSysMonPsu instance.
110 * @param        Mask is the 64 bit-mask of the interrupts to be disabled.
111 *               Bit positions of 1 will be disabled. Bit positions of 0 will
112 *               keep the previous setting. This mask is formed by OR'ing
113 *               XSYSMONPSU_IDR_0_* and XSYSMONPSU_IDR_1_* bits defined in
114 *               xsysmonpsu_hw.h.
115 *
116 * @return       None.
117 *
118 * @note         None.
119 *
120 *****************************************************************************/
121 void XSysMonPsu_IntrDisable(XSysMonPsu *InstancePtr, u64 Mask)
122 {
123         u32 RegValue;
124
125         /* Assert the arguments. */
126         Xil_AssertVoid(InstancePtr != NULL);
127         Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
128
129         /* Disable the specified interrupts in the AMS Interrupt Disable Register. */
130         RegValue = XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
131                                         XSYSMONPSU_IDR_0_OFFSET);
132         RegValue |= (u32)(Mask & (u64)XSYSMONPSU_IXR_0_MASK);
133         XSysmonPsu_WriteReg(InstancePtr->Config.BaseAddress + XSYSMONPSU_IDR_0_OFFSET,
134                           RegValue);
135
136         RegValue = XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
137                                         XSYSMONPSU_IDR_1_OFFSET);
138         RegValue |= (u32)((Mask >> XSYSMONPSU_IXR_1_SHIFT) & XSYSMONPSU_IXR_1_MASK);
139         XSysmonPsu_WriteReg(InstancePtr->Config.BaseAddress + XSYSMONPSU_IDR_1_OFFSET,
140                           RegValue);
141 }
142
143 /****************************************************************************/
144 /**
145 *
146 * This function returns the enabled interrupts read from the Interrupt Enable
147 * Register (IER). Use the XSYSMONPSU_IER_0_* and XSYSMONPSU_IER_1_* constants
148 * defined in xsysmonpsu_hw.h to interpret the returned value.
149 *
150 * @param        InstancePtr is a pointer to the XSysMonPsu instance.
151 *
152 * @return       A 64-bit value representing the contents of the Interrupt Mask
153 *                       Registers (IMR1 IMR0).
154 *
155 * @note         None.
156 *
157 *****************************************************************************/
158 u64 XSysMonPsu_IntrGetEnabled(XSysMonPsu *InstancePtr)
159 {
160         u64 MaskedInterrupts;
161
162         /* Assert the arguments. */
163         Xil_AssertNonvoid(InstancePtr != NULL);
164         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
165
166         /* Return the value read from the AMS Interrupt Mask Register. */
167         MaskedInterrupts = (u64)XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
168                          XSYSMONPSU_IMR_0_OFFSET) & (u64)XSYSMONPSU_IXR_0_MASK;
169         MaskedInterrupts |= ((u64)XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
170                          XSYSMONPSU_IMR_1_OFFSET) & (u64)XSYSMONPSU_IXR_1_MASK)
171                           << XSYSMONPSU_IXR_1_SHIFT;
172
173         return (~MaskedInterrupts);
174 }
175
176 /****************************************************************************/
177 /**
178 *
179 * This function returns the interrupt status read from Interrupt Status
180 * Register(ISR). Use the XSYSMONPSU_ISR_0_* and XSYSMONPSU_ISR_1_ constants
181 * defined in xsysmonpsu_hw.h to interpret the returned value.
182 *
183 * @param        InstancePtr is a pointer to the XSysMonPsu instance.
184 *
185 * @return       A 64-bit value representing the contents of the Interrupt Status
186 *                       Registers (ISR1 ISR0).
187 *
188 * @note         None.
189 *
190 *****************************************************************************/
191 u64 XSysMonPsu_IntrGetStatus(XSysMonPsu *InstancePtr)
192 {
193         u64 IntrStatusRegister;
194
195         /* Assert the arguments. */
196         Xil_AssertNonvoid(InstancePtr != NULL);
197         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
198
199         /* Return the value read from the AMS ISR. */
200         IntrStatusRegister = (u64)XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
201                            XSYSMONPSU_ISR_0_OFFSET) & (u64)XSYSMONPSU_IXR_0_MASK;
202         IntrStatusRegister |= ((u64)XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
203                            XSYSMONPSU_ISR_1_OFFSET) & (u64)XSYSMONPSU_IXR_1_MASK)
204                            << XSYSMONPSU_IXR_1_SHIFT;
205
206         return IntrStatusRegister;
207 }
208
209 /****************************************************************************/
210 /**
211 *
212 * This function clears the specified interrupts in the Interrupt Status
213 * Register (ISR).
214 *
215 * @param        InstancePtr is a pointer to the XSysMonPsu instance.
216 * @param        Mask is the 64 bit-mask of the interrupts to be cleared.
217 *               Bit positions of 1 will be cleared. Bit positions of 0 will not
218 *               change the previous interrupt status. This mask is formed by
219 *               OR'ing the XSYSMONPSU_ISR_0_* and XSYSMONPSU_ISR_1_* bits
220 *               which are defined in xsysmonpsu_hw.h.
221 *
222 * @return       None.
223 *
224 * @note         None.
225 *
226 *****************************************************************************/
227 void XSysMonPsu_IntrClear(XSysMonPsu *InstancePtr, u64 Mask)
228 {
229         u32 RegValue;
230
231         /* Assert the arguments. */
232         Xil_AssertVoid(InstancePtr != NULL);
233         Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
234
235         /* Clear the specified interrupts in the Interrupt Status register. */
236         RegValue = XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
237                                         XSYSMONPSU_ISR_0_OFFSET);
238         RegValue &= (u32)(Mask & (u64)XSYSMONPSU_IXR_0_MASK);
239         XSysmonPsu_WriteReg(InstancePtr->Config.BaseAddress + XSYSMONPSU_ISR_0_OFFSET,
240                           RegValue);
241
242         RegValue = XSysmonPsu_ReadReg(InstancePtr->Config.BaseAddress +
243                                         XSYSMONPSU_ISR_1_OFFSET);
244         RegValue &= (u32)((Mask >> XSYSMONPSU_IXR_1_SHIFT) & XSYSMONPSU_IXR_1_MASK);
245         XSysmonPsu_WriteReg(InstancePtr->Config.BaseAddress + XSYSMONPSU_ISR_1_OFFSET,
246                           RegValue);
247 }
248
249
250 /** @} */