1 /******************************************************************************
3 * Copyright (C) 2011 - 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
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
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 xl2cc_counter.c
37 * This file contains APIs for configuring and controlling the event counters
38 * in PL310 L2 cache controller. For more information about the event counters,
39 * see xl2cc_counter.h.
42 * MODIFICATION HISTORY:
44 * Ver Who Date Changes
45 * ----- ---- -------- -----------------------------------------------
46 * 1.00a sdm 07/11/11 First release
47 * 3.07a asa 08/30/12 Updated for CR 675636 to provide the L2 Base Address
51 ******************************************************************************/
53 /***************************** Include Files *********************************/
56 #include "xparameters_ps.h"
57 #include "xl2cc_counter.h"
60 /************************** Constant Definitions ****************************/
62 /**************************** Type Definitions ******************************/
64 /***************** Macros (Inline Functions) Definitions ********************/
66 /************************** Variable Definitions *****************************/
68 /************************** Function Prototypes ******************************/
70 void XL2cc_EventCtrReset(void);
72 /******************************************************************************/
74 /****************************************************************************/
77 * @brief This function initializes the event counters in L2 Cache controller
78 * with a set of event codes specified by the user.
80 * @param Event0: Event code for counter 0.
81 * @param Event1: Event code for counter 1.
85 * @note The definitions for event codes XL2CC_* can be found in
88 *****************************************************************************/
89 void XL2cc_EventCtrInit(s32 Event0, s32 Event1)
92 /* Write event code into cnt1 cfg reg */
93 *((volatile u32*)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNT1_CTRL_OFFSET)) = (((u32)Event1) << 2);
95 /* Write event code into cnt0 cfg reg */
96 *((volatile u32*)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNT0_CTRL_OFFSET)) = (((u32)Event0) << 2);
99 XL2cc_EventCtrReset();
103 /****************************************************************************/
106 * @brief This function starts the event counters in L2 Cache controller.
114 *****************************************************************************/
115 void XL2cc_EventCtrStart(void)
118 LocalPtr = (u32 *)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNTRL_OFFSET);
119 XL2cc_EventCtrReset();
122 /* *((volatile u32*)((void *)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNTRL_OFFSET))) = 1 */
126 /****************************************************************************/
129 * @brief This function disables the event counters in L2 Cache controller,
130 * saves the counter values and resets the counters.
132 * @param EveCtr0: Output parameter which is used to return the value
133 * in event counter 0.
134 * EveCtr1: Output parameter which is used to return the value
135 * in event counter 1.
141 *****************************************************************************/
142 void XL2cc_EventCtrStop(u32 *EveCtr0, u32 *EveCtr1)
144 /* Disable counter */
145 *((volatile u32*) (XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNTRL_OFFSET)) = 0U;
147 /* Save counter values */
148 *EveCtr1 = *((volatile u32*)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNT1_VAL_OFFSET));
149 *EveCtr0 = *((volatile u32*)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNT0_VAL_OFFSET));
151 XL2cc_EventCtrReset();
154 /****************************************************************************/
157 * @brief This function resets the event counters in L2 Cache controller.
165 *****************************************************************************/
166 void XL2cc_EventCtrReset(void)
168 *((volatile u32*)(XPS_L2CC_BASEADDR + XPS_L2CC_EVNT_CNTRL_OFFSET)) = 0x6U;