1 /******************************************************************************
3 * Copyright (C) 2016 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 /*****************************************************************************/
35 * @file xsysmonpsu_intr.c
37 * This file contains functions related to SYSMONPSU interrupt handling.
40 * MODIFICATION HISTORY:
42 * Ver Who Date Changes
43 * ----- ----- -------- -----------------------------------------------
44 * 1.0 kvn 12/15/15 First release
47 ******************************************************************************/
49 /***************************** Include Files *********************************/
51 #include "xsysmonpsu.h"
53 /************************** Constant Definitions *****************************/
55 /**************************** Type Definitions *******************************/
57 /***************** Macros (Inline Functions) Definitions *********************/
59 /************************** Variable Definitions *****************************/
61 /************************** Function Prototypes ******************************/
63 /************************** Variable Definitions ****************************/
65 /****************************************************************************/
68 * This function enables the specified interrupts in the device.
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
81 *****************************************************************************/
82 void XSysMonPsu_IntrEnable(XSysMonPsu *InstancePtr, u64 Mask)
86 /* Assert the arguments. */
87 Xil_AssertVoid(InstancePtr != NULL);
88 Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
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,
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,
104 /****************************************************************************/
107 * This function disables the specified interrupts in the device.
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
120 *****************************************************************************/
121 void XSysMonPsu_IntrDisable(XSysMonPsu *InstancePtr, u64 Mask)
125 /* Assert the arguments. */
126 Xil_AssertVoid(InstancePtr != NULL);
127 Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
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,
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,
143 /****************************************************************************/
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.
150 * @param InstancePtr is a pointer to the XSysMonPsu instance.
152 * @return A 64-bit value representing the contents of the Interrupt Mask
153 * Registers (IMR1 IMR0).
157 *****************************************************************************/
158 u64 XSysMonPsu_IntrGetEnabled(XSysMonPsu *InstancePtr)
160 u64 MaskedInterrupts;
162 /* Assert the arguments. */
163 Xil_AssertNonvoid(InstancePtr != NULL);
164 Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
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;
173 return (~MaskedInterrupts);
176 /****************************************************************************/
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.
183 * @param InstancePtr is a pointer to the XSysMonPsu instance.
185 * @return A 64-bit value representing the contents of the Interrupt Status
186 * Registers (ISR1 ISR0).
190 *****************************************************************************/
191 u64 XSysMonPsu_IntrGetStatus(XSysMonPsu *InstancePtr)
193 u64 IntrStatusRegister;
195 /* Assert the arguments. */
196 Xil_AssertNonvoid(InstancePtr != NULL);
197 Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
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;
206 return IntrStatusRegister;
209 /****************************************************************************/
212 * This function clears the specified interrupts in the Interrupt Status
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.
226 *****************************************************************************/
227 void XSysMonPsu_IntrClear(XSysMonPsu *InstancePtr, u64 Mask)
231 /* Assert the arguments. */
232 Xil_AssertVoid(InstancePtr != NULL);
233 Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
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,
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,