]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/libsrc/axipmon_v6_4/src/xaxipmon.h
Update BSP source files for UltraScale Cortex-A53 and Cortex-R5 and Microblaze to...
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / libsrc / axipmon_v6_4 / src / xaxipmon.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2007 - 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 xaxipmon.h
36 * @addtogroup axipmon_v6_3
37 * @{
38 * @details
39 *
40 * The XAxiPmon driver supports the Xilinx AXI Performance Monitor device.
41 *
42 * The AXI Performance Monitor device provides following features:
43 *
44 *       Configurable number of Metric Counters and Incrementers
45 *       Computes performance metrics for Agents connected to
46 *       monitor slots (Up to 8 slots)
47 *
48 * The following Metrics can be computed:
49 *
50 * Metrics computed for an AXI4 MM agent:
51 *       Write Request Count: Total number of write requests by/to the agent.
52 *       Read Request Count: Total number of read requests given by/to the
53 *                           agent.
54 *       Read Latency: It is defined as the time from the start of read address
55 *                     transaction to the beginning of the read data service.
56 *       Write Latency: It is defined as the period needed a master completes
57 *                      write data transaction, i.e. from write address
58 *                      transaction to write response from slave.
59 *       Write Byte Count: Total number of bytes written by/to the agent.
60 *                         This metric is helpful when calculating the
61 *                         throughput of the system.
62 *       Read Byte Count: Total number of bytes read from/by the agent.
63 *       Average Write Latency: Average write latency seen by the agent.
64 *                              It can be derived from total write latency
65 *                              and the write request count.
66 *       Average Read Latency: Average read latency seen by the agent. It can be
67 *                             derived from total read latency and the read
68 *                             request count.
69 *       Master Write Idle Cycle Count: Number of idle cycles caused by the
70 *                                      masters during write transactions to
71 *                                      the slave.
72 *       Slave Write Idle Cycle Count: Number of idle cycles caused by this slave
73 *                                     during write transactions to the slave.
74 *       Master Read Idle Cycle Count: Number of idle cycles caused by the
75 *                                     master during read transactions to the
76 *                                     slave.
77 *       Slave Read Idle Cycle Count: Number of idle cycles caused by this slave
78 *                                    during read transactions to the slave.
79 *
80 * Metrics computed for an AXI4-Stream agent:
81 *
82 *       Transfer Cycle Count: Total number of writes by/to the agent.
83 *       Data Byte Count: Total number of data bytes written by/to the agent.
84 *                        This metric helps in calculating the throughput
85 *                        of the system.
86 *       Position Byte Count: Total number of position bytes transferred.
87 *       Null Byte Count: Total number of null bytes transferred.
88 *       Packet Count: Total number of packets transferred.
89 *
90 * There are three modes : Advanced, Profile and Trace.
91 * - Advanced mode has 10 Mertic Counters, Sampled Metric Counters, Incrementors
92 *   and Sampled Incrementors.
93 * - Profile mode has only 47 Metric Counters and Sampled Metric Counters.
94 * - Trace mode has no Counters.
95 * User should refer to the hardware device specification for detailed
96 * information about the device.
97 *
98 * This header file contains the prototypes of driver functions that can
99 * be used to access the AXI Performance Monitor device.
100 *
101 *
102 * <b> Initialization and Configuration </b>
103 *
104 * The device driver enables higher layer software (e.g., an application) to
105 * communicate to the AXI Performance Monitor device.
106 *
107 * XAxiPmon_CfgInitialize() API is used to initialize the AXI Performance Monitor
108 * device. The user needs to first call the XAxiPmon_LookupConfig() API which
109 * returns the Configuration structure pointer which is passed as a parameter to
110 * the XAxiPmon_CfgInitialize() API.
111 *
112 *
113 * <b>Interrupts</b>
114 *
115 * The AXI Performance Monitor does not support Interrupts
116 *
117 *
118 * <b> Virtual Memory </b>
119 *
120 * This driver supports Virtual Memory. The RTOS is responsible for calculating
121 * the correct device base address in Virtual Memory space.
122 *
123 *
124 * <b> Threads </b>
125 *
126 * This driver is not thread safe. Any needs for threads or thread mutual
127 * exclusion must be satisfied by the layer above this driver.
128 *
129 * <b> Asserts </b>
130 *
131 * Asserts are used within all Xilinx drivers to enforce constraints on argument
132 * values. Asserts can be turned off on a system-wide basis by defining, at
133 * compile time, the NDEBUG identifier. By default, asserts are turned on and it
134 * is recommended that users leave asserts on during development.
135 *
136 *
137 * <b> Building the driver </b>
138 *
139 * The XAxiPmon driver is composed of several source files. This allows the user
140 * to build and link only those parts of the driver that are necessary.
141 *
142 * <b> Limitations of the driver </b>
143 *
144 *
145 * <br><br>
146 *
147 * <pre>
148 *
149 * MODIFICATION HISTORY:
150 *
151 * Ver   Who    Date     Changes
152 * ----- -----  -------- -----------------------------------------------------
153 * 1.00a bss    02/27/12 First release
154 * 2.00a bss    06/23/12 Updated to support v2_00a version of IP.
155 * 3.00a bss    09/03/12 To support v2_01_a version of IP:
156 *                       Deleted XAxiPmon_SetAgent, XAxiPmon_GetAgent APIs and
157 *                       added XAPM_FLAG_EVENT, XAPM_FLAG_EVNTSTAR,
158 *                       XAPM_FLAG_EVNTSTOP.
159 *                       Deleted XAxiPmon_SetAgent, XAxiPmon_GetAgent APIs and
160 *                       modified XAxiPmon_SetMetrics, XAxiPmon_GetMetrics APIs
161 *                       in xaxipmon.c
162 *                       Deleted XAPM_AGENT_OFFSET Macro in xaxipmon_hw.h
163 * 3.01a bss    10/25/12 To support new version of IP:
164 *                       Added XAPM_MCXLOGEN_OFFSET macros in xaxipmon_hw.h.
165 *                       Added XAxiPmon_SetMetricCounterCutOff,
166 *                       XAxiPmon_GetMetricCounterCutOff,
167 *                       XAxiPmon_EnableExternalTrigger and
168 *                       XAxiPmon_DisableExternalTrigger APIs in xaxipmon.c
169 *                       Modified XAxiPmon_SetMetrics and XAxiPmon_GetMetrics
170 *                       (CR #683746) in xaxipmon.c
171 *                       Added XAxiPmon_EnableEventLog,
172 *                       XAxiPmon_DisableMetricsCounter,
173 *                       XAxiPmon_EnableMetricsCounter APIs in xaxipmon.c to
174 *                       replace macros in this file.
175 *                       Added XAPM_FLAG_XXX macros.
176 *                       Added XAxiPmon_StartCounters and XAxiPmon_StopCounters
177 *                       APIs (CR #683799).
178 *                       Added XAxiPmon_StartEventLog and XAxiPmon_StopEventLog
179 *                       APIs (CR #683801).
180 *                       Added XAxiPmon_GetMetricName API (CR #683803).
181 *                       Deleted XAxiPmon_SetAgent, XAxiPmon_GetAgent
182 *                       declarations (CR #677337)
183 * 4.00a bss    01/17/13 To support new version of IP:
184 *                       Added XAPM_METRIC_SET_12 to XAPM_METRIC_SET_15 macros.
185 *                       Added XAxiPmon_SetLogEnableRanges,
186 *                       XAxiPmon_GetLogEnableRanges,
187 *                       XAxiPmon_EnableMetricCounterTrigger,
188 *                       XAxiPmon_DisableMetricCounterTrigger,
189 *                       XAxiPmon_EnableEventLogTrigger,
190 *                       XAxiPmon_DisableEventLogTrigger,
191 *                       XAxiPmon_SetWriteLatencyId,
192 *                       XAxiPmon_SetReadLatencyId,
193 *                       XAxiPmon_GetWriteLatencyId,
194 *                       XAxiPmon_GetReadLatencyId APIs and removed
195 *                       XAxiPmon_SetMetricCounterCutOff,
196 *                       XAxiPmon_GetMetricCounterCutOff,
197 *                       XAxiPmon_EnableExternalTrigger and
198 *                       XAxiPmon_DisableExternalTrigger APIs in xaxipmon.c
199 *                       Added XAPM_LATENCYID_OFFSET,
200 *                       XAPM_CR_EVTLOG_EXTTRIGGER_MASK,
201 *                       XAPM_LATENCYID_RID_MASK and XAPM_LATENCYID_WID_MASK in
202 *                       xaxipmon_hw.h
203 * 5.00a bss   08/26/13  To support new version of IP:
204 *                       XAxiPmon_SampleMetrics Macro.
205 *                       Modified XAxiPmon_CfgInitialize, Assert functions
206 *                       Added XAxiPmon_GetMetricCounter,
207 *                       XAxiPmon_SetSampleInterval, XAxiPmon_GetSampleInterval,
208 *                       XAxiPmon_SetWrLatencyStart, XAxiPmon_SetWrLatencyEnd,
209 *                       XAxiPmon_SetRdLatencyStart, XAxiPmon_SetRdLatencyEnd,
210 *                       XAxiPmon_GetWrLatencyStart, XAxiPmon_GetWrLatencyEnd,
211 *                       XAxiPmon_GetRdLatencyStart, XAxiPmon_GetRdLatencyEnd,
212 *                       XAxiPmon_SetWriteIdMask, XAxiPmon_SetReadIdMask,
213 *                       XAxiPmon_GetWriteIdMask and XAxiPmon_GetReadIdMask APIs
214 *                       Renamed :
215 *                       XAxiPmon_SetWriteLatencyId to
216 *                       XAxiPmon_SetWriteId, XAxiPmon_SetReadLatencyId to
217 *                       XAxiPmon_SetReadId, XAxiPmon_GetWriteLatencyId to
218 *                       XAxiPmon_GetWriteId and XAxiPmon_SetReadLatencyId to
219 *                       XAxiPmon_GetReadId. in xaxipmon.c
220 *                       Added Macros XAPM_MC10_OFFSET to XAPM_MC47_OFFSET,
221 *                       XAPM_SMC10_OFFSET to XAPM_SMC47_OFFSET,
222 *                       XAPM_IDMASK_OFFSET, XAPM_CR_IDFILTER_ENABLE_MASK,
223 *                       XAPM_CR_WRLATENCY_START_MASK,
224 *                       XAPM_CR_WRLATENCY_END_MASK,
225 *                       XAPM_CR_RDLATENCY_START_MASK,
226 *                       XAPM_CR_RDLATENCY_END_MASK and
227 *                       XAPM_MAX_COUNTERS_PROFILE.
228 *                       Renamed:
229 *                       XAPM_LATENCYID_OFFSET to XAPM_ID_OFFSET,
230 *                       XAPM_LATENCYID_RID_MASK to XAPM_ID_RID_MASK,
231 *                       XAPM_LATENCYID_WID_MASK to XAPM_ID_WID_MASK.
232 *                       in xaxipmon_hw.h.
233 *                       Modified driver tcl to generate new parameters
234 *                       ScaleFactor, ModeProfile, ModeTrace and ModeAdvanced
235 *                       in Config structure.
236 * 6.0   adk  19/12/13 Updated as per the New Tcl API's
237 * 6.1   adk  16/04/14 Updated the driver tcl for the newly added parameters in
238 *                     The Axi pmon IP.
239 * 6.2   bss  04/21/14   Updated XAxiPmon_CfgInitialize in xaxipmon.c to Reset
240 *                       counters and FIFOs based on Modes(CR#782671). And if
241 *                       both profile and trace modes are present set mode as
242 *                       Advanced.
243 * 6.2   bss  03/02/15   To support Zynq MP APM:
244 *                                               Added Is32BitFiltering in XAxiPmon_Config structure.
245 *                                               Updated XAxiPmon_SetWriteId, XAxiPmon_SetReadId,
246 *                                               XAxiPmon_GetWriteId, XAxiPmon_GetReadId
247 *                                               XAxiPmon_SetWriteIdMask, XAxiPmon_SetReadIdMask
248 *                                               XAxiPmon_GetWriteIdMask, XAxiPmon_GetReadIdMask
249 *                                               functions in xaxipmon.c.
250 *                                               Added XAPM_RID_OFFSET and XAPM_RIDMASK_OFFSET in
251 *                                               xaxipmon_hw.h
252 *
253 * 6.3   kvn  07/02/15   Modified code according to MISRA-C:2012 guidelines.
254 * 6.4   sk   11/10/15 Used UINTPTR instead of u32 for Baseaddress CR# 867425.
255 *                     Changed the prototype of XAxiPmon_CfgInitialize API.
256 * </pre>
257 *
258 *****************************************************************************/
259 #ifndef XAXIPMON_H /* Prevent circular inclusions */
260 #define XAXIPMON_H /* by using protection macros  */
261
262 #ifdef __cplusplus
263 extern "C" {
264 #endif
265
266 /***************************** Include Files ********************************/
267
268 #include "xil_types.h"
269 #include "xil_assert.h"
270 #include "xstatus.h"
271 #include "xaxipmon_hw.h"
272
273 /************************** Constant Definitions ****************************/
274
275
276 /**
277  * @name Macro for Maximum number of Counters
278  *
279  * @{
280  */
281 #define XAPM_MAX_COUNTERS               10U /**< Maximum number of Counters */
282 #define XAPM_MAX_COUNTERS_PROFILE       48U /**< Maximum number of Counters */
283
284 /*@}*/
285
286
287 /**
288  * @name Indices for Metric Counters and Sampled Metric Coounters used with
289  *       XAxiPmon_GetMetricCounter and XAxiPmon_GetSampledMetricCounter APIs
290  * @{
291  */
292
293 #define XAPM_METRIC_COUNTER_0   0U /**< Metric Counter 0 Register Index */
294 #define XAPM_METRIC_COUNTER_1   1U /**< Metric Counter 1 Register Index */
295 #define XAPM_METRIC_COUNTER_2   2U /**< Metric Counter 2 Register Index */
296 #define XAPM_METRIC_COUNTER_3   3U /**< Metric Counter 3 Register Index */
297 #define XAPM_METRIC_COUNTER_4   4U /**< Metric Counter 4 Register Index */
298 #define XAPM_METRIC_COUNTER_5   5U /**< Metric Counter 5 Register Index */
299 #define XAPM_METRIC_COUNTER_6   6U /**< Metric Counter 6 Register Index */
300 #define XAPM_METRIC_COUNTER_7   7U /**< Metric Counter 7 Register Index */
301 #define XAPM_METRIC_COUNTER_8   8U /**< Metric Counter 8 Register Index */
302 #define XAPM_METRIC_COUNTER_9   9U /**< Metric Counter 9 Register Index */
303
304 /*@}*/
305
306 /**
307  * @name Indices for Incrementers and Sampled Incrementers used with
308  *       XAxiPmon_GetIncrementer and XAxiPmon_GetSampledIncrementer APIs
309  * @{
310  */
311
312 #define XAPM_INCREMENTER_0      0U /**< Metric Counter 0 Register Index */
313 #define XAPM_INCREMENTER_1      1U /**< Metric Counter 0 Register Index */
314 #define XAPM_INCREMENTER_2      2U /**< Metric Counter 0 Register Index */
315 #define XAPM_INCREMENTER_3      3U /**< Metric Counter 0 Register Index */
316 #define XAPM_INCREMENTER_4      4U /**< Metric Counter 0 Register Index */
317 #define XAPM_INCREMENTER_5      5U /**< Metric Counter 0 Register Index */
318 #define XAPM_INCREMENTER_6      6U /**< Metric Counter 0 Register Index */
319 #define XAPM_INCREMENTER_7      7U /**< Metric Counter 0 Register Index */
320 #define XAPM_INCREMENTER_8      8U /**< Metric Counter 0 Register Index */
321 #define XAPM_INCREMENTER_9      9U /**< Metric Counter 0 Register Index */
322
323 /*@}*/
324
325 /**
326  * @name Macros for Metric Selector Settings
327  * @{
328  */
329
330 #define XAPM_METRIC_SET_0               0U /**< Write Transaction Count */
331 #define XAPM_METRIC_SET_1               1U /**< Read Transaction Count */
332 #define XAPM_METRIC_SET_2               2U /**< Write Byte Count */
333 #define XAPM_METRIC_SET_3               3U /**< Read Byte Count */
334 #define XAPM_METRIC_SET_4               4U /**< Write Beat Count */
335 #define XAPM_METRIC_SET_5               5U /**< Total Read Latency */
336 #define XAPM_METRIC_SET_6               6U /**< Total Write Latency */
337 #define XAPM_METRIC_SET_7               7U /**< Slv_Wr_Idle_Cnt */
338 #define XAPM_METRIC_SET_8               8U /**< Mst_Rd_Idle_Cnt */
339 #define XAPM_METRIC_SET_9               9U /**< Num_BValids */
340 #define XAPM_METRIC_SET_10              10U /**< Num_WLasts */
341 #define XAPM_METRIC_SET_11              11U /**< Num_RLasts */
342 #define XAPM_METRIC_SET_12              12U /**< Minimum Write Latency */
343 #define XAPM_METRIC_SET_13              13U /**< Maximum Write Latency */
344 #define XAPM_METRIC_SET_14              14U /**< Minimum Read Latency */
345 #define XAPM_METRIC_SET_15              15U /**< Maximum Read Latency */
346 #define XAPM_METRIC_SET_16              16U /**< Transfer Cycle Count */
347 #define XAPM_METRIC_SET_17              17U /**< Packet Count */
348 #define XAPM_METRIC_SET_18              18U /**< Data Byte Count */
349 #define XAPM_METRIC_SET_19              19U /**< Position Byte Count */
350 #define XAPM_METRIC_SET_20              20U /**< Null Byte Count */
351 #define XAPM_METRIC_SET_21              21U /**< Slv_Idle_Cnt */
352 #define XAPM_METRIC_SET_22              22U /**< Mst_Idle_Cnt */
353 #define XAPM_METRIC_SET_30              30U /**< External event count */
354
355
356 /*@}*/
357
358
359 /**
360  * @name Macros for Maximum number of Agents
361  * @{
362  */
363
364 #define XAPM_MAX_AGENTS         8U /**< Maximum number of Agents */
365
366 /*@}*/
367
368 /**
369  * @name Macros for Flags in Flag Enable Control Register
370  * @{
371  */
372
373 #define XAPM_FLAG_WRADDR        0x00000001 /**< Write Address Flag */
374 #define XAPM_FLAG_FIRSTWR       0x00000002 /**< First Write Flag */
375 #define XAPM_FLAG_LASTWR        0x00000004 /**< Last Write Flag */
376 #define XAPM_FLAG_RESPONSE      0x00000008 /**< Response Flag */
377 #define XAPM_FLAG_RDADDR        0x00000010 /**< Read Address Flag */
378 #define XAPM_FLAG_FIRSTRD       0x00000020 /**< First Read Flag */
379 #define XAPM_FLAG_LASTRD        0x00000040 /**< Last Read Flag */
380 #define XAPM_FLAG_SWDATA        0x00010000 /**< Software-written Data Flag */
381 #define XAPM_FLAG_EVENT         0x00020000 /**< Last Read Flag */
382 #define XAPM_FLAG_EVNTSTOP      0x00040000 /**< Last Read Flag */
383 #define XAPM_FLAG_EVNTSTART     0x00080000 /**< Last Read Flag */
384 #define XAPM_FLAG_GCCOVF        0x00100000 /**< Global Clock Counter Overflow
385                                              *  Flag */
386 #define XAPM_FLAG_SCLAPSE       0x00200000 /**< Sample Counter Lapse Flag */
387 #define XAPM_FLAG_MC0           0x00400000U /**< Metric Counter 0 Flag */
388 #define XAPM_FLAG_MC1           0x00800000U /**< Metric Counter 1 Flag */
389 #define XAPM_FLAG_MC2           0x01000000U /**< Metric Counter 2 Flag */
390 #define XAPM_FLAG_MC3           0x02000000U /**< Metric Counter 3 Flag */
391 #define XAPM_FLAG_MC4           0x04000000U /**< Metric Counter 4 Flag */
392 #define XAPM_FLAG_MC5           0x08000000U /**< Metric Counter 5 Flag */
393 #define XAPM_FLAG_MC6           0x10000000U /**< Metric Counter 6 Flag */
394 #define XAPM_FLAG_MC7           0x20000000U /**< Metric Counter 7 Flag */
395 #define XAPM_FLAG_MC8           0x40000000U /**< Metric Counter 8 Flag */
396 #define XAPM_FLAG_MC9           0x80000000U /**< Metric Counter 9 Flag */
397
398 /*@}*/
399
400 /**
401  * @name Macros for Read/Write Latency Start and End points
402  * @{
403  */
404 #define XAPM_LATENCY_ADDR_ISSUE         0U /**< Address Issue as start
405                                         point for Latency calculation*/
406 #define XAPM_LATENCY_ADDR_ACCEPT        1U /**< Address Acceptance as start
407                                         point for Latency calculation*/
408 #define XAPM_LATENCY_LASTRD             0U /**< Last Read as end point for
409                                         Latency calculation */
410 #define XAPM_LATENCY_LASTWR             0U /**< Last Write as end point for
411                                         Latency calculation */
412 #define XAPM_LATENCY_FIRSTRD            1U /**< First Read as end point for
413                                         Latency calculation */
414 #define XAPM_LATENCY_FIRSTWR            1U /**< First Write as end point for
415                                         Latency calculation */
416
417 /*@}*/
418
419 /**
420  * @name Macros for Modes of APM
421  * @{
422  */
423
424 #define XAPM_MODE_TRACE                 2U /**< APM in Trace mode */
425
426 #define XAPM_MODE_PROFILE               1U /**< APM in Profile mode */
427
428 #define XAPM_MODE_ADVANCED              0U /**< APM in Advanced mode */
429
430 /*@}*/
431
432 /**************************** Type Definitions *******************************/
433
434 /**
435  * This typedef contains configuration information for the AXI Performance
436  * Monitor device.
437  */
438 typedef struct {
439         u16 DeviceId;                   /**< Unique ID of device */
440         UINTPTR BaseAddress;            /**< Device base address */
441         s32 GlobalClkCounterWidth;      /**< Global Clock Counter Width */
442         s32 MetricSampleCounterWidth ;  /**< Metric Sample Counters Width */
443         u8  IsEventCount;               /**< Event Count Enabled 1 - enabled
444                                                            0 - not enabled */
445         u8  NumberofSlots;              /**< Number of Monitor Slots */
446         u8  NumberofCounters;           /**< Number of Counters */
447         u8  HaveSampledCounters;        /**< Have Sampled Counters 1 - present
448                                                             0 - Not present */
449         u8 IsEventLog;                  /**< Event Logging Enabled 1 - enabled
450                                                             0 - Not enabled */
451         u32 FifoDepth;                  /**< Event Log FIFO Depth */
452         u32 FifoWidth;                  /**< Event Log FIFO Width */
453         u32 TidWidth;                   /**< Streaming Interface TID Width */
454         u8  ScaleFactor;                /**< Event Count Scaling factor */
455         u8  ModeAdvanced;               /**< Advanced Mode */
456         u8  ModeProfile;                /**< Profile Mode */
457         u8  ModeTrace;                  /**< Trace Mode */
458         u8  Is32BitFiltering;   /**< 32 bit filtering enabled */
459 } XAxiPmon_Config;
460
461
462 /**
463  * The driver's instance data. The user is required to allocate a variable
464  * of this type for every AXI Performance Monitor device in system. A pointer
465  * to a variable of this type is then passed to the driver API functions.
466  */
467 typedef struct {
468         XAxiPmon_Config Config; /**< XAxiPmon_Config of current device */
469         u32  IsReady;           /**< Device is initialized and ready  */
470         u8   Mode;              /**< APM Mode */
471 } XAxiPmon;
472
473 /***************** Macros (Inline Functions) Definitions ********************/
474
475
476 /****************************************************************************/
477 /**
478 *
479 * This routine enables the Global Interrupt.
480 *
481 * @param        InstancePtr is a pointer to the XAxiPmon instance.
482 *
483 * @return       None.
484 *
485 * @note         C-Style signature:
486 *               void XAxiPmon_IntrGlobalEnable(XAxiPmon *InstancePtr)
487 *
488 *****************************************************************************/
489 #define XAxiPmon_IntrGlobalEnable(InstancePtr)                  \
490         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress,    \
491                         XAPM_GIE_OFFSET, 1)
492
493
494 /****************************************************************************/
495 /**
496 *
497 * This routine disables the Global Interrupt.
498 *
499 * @param        InstancePtr is a pointer to the XAxiPmon instance.
500 *
501 * @return       None.
502 *
503 * @note         C-Style signature:
504 *               void XAxiPmon_IntrGlobalDisable(XAxiPmon *InstancePtr)
505 *
506 *****************************************************************************/
507 #define XAxiPmon_IntrGlobalDisable(InstancePtr)                         \
508         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress,            \
509                                 XAPM_GIE_OFFSET, 0)
510
511
512 /****************************************************************************/
513 /**
514 *
515 * This routine enables interrupt(s). Use the XAPM_IXR_* constants defined in
516 * xaxipmon_hw.h to create the bit-mask to enable interrupts.
517 *
518 * @param        InstancePtr is a pointer to the XAxiPmon instance.
519 * @param        Mask is the mask to enable. Bit positions of 1 will be enabled.
520 *               Bit positions of 0 will keep the previous setting. This mask is
521 *               formed by OR'ing XAPM_IXR__* bits defined in xaxipmon_hw.h.
522 *
523 * @return       None.
524 *
525 * @note         C-Style signature:
526 *               void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
527 *
528 *****************************************************************************/
529 #define XAxiPmon_IntrEnable(InstancePtr, Mask)                               \
530         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IE_OFFSET, \
531                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
532                         XAPM_IE_OFFSET) | (Mask));
533
534
535 /****************************************************************************/
536 /**
537 *
538 * This routine disable interrupt(s). Use the XAPM_IXR_* constants defined in
539 * xaxipmon_hw.h to create the bit-mask to disable interrupts.
540 *
541 * @param        InstancePtr is a pointer to the XAxiPmon instance.
542 * @param        Mask is the mask to disable. Bit positions of 1 will be
543 *               disabled. Bit positions of 0 will keep the previous setting.
544 *               This mask is formed by OR'ing XAPM_IXR_* bits defined in
545 *               xaxipmon_hw.h.
546 *
547 * @return       None.
548 *
549 * @note         C-Style signature:
550 *               void XAxiPmon_IntrEnable(XAxiPmon *InstancePtr, u32 Mask)
551 *
552 *****************************************************************************/
553 #define XAxiPmon_IntrDisable(InstancePtr, Mask)                              \
554         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IE_OFFSET, \
555                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
556                         XAPM_IE_OFFSET) | (Mask));
557
558 /****************************************************************************/
559 /**
560 *
561 * This routine clears the specified interrupt(s).
562 *
563 * @param        InstancePtr is a pointer to the XAxiPmon instance.
564 * @param        Mask is the mask to clear. Bit positions of 1 will be cleared.
565 *               This mask is formed by OR'ing XAPM_IXR_* bits defined in
566 *               xaxipmon_hw.h.
567 *
568 * @return       None.
569 *
570 * @note         C-Style signature:
571 *               void XAxiPmon_IntrClear(XAxiPmon *InstancePtr, u32 Mask)
572 *
573 *****************************************************************************/
574 #define XAxiPmon_IntrClear(InstancePtr, Mask)                                \
575         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_IS_OFFSET, \
576                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
577                         XAPM_IS_OFFSET) | (Mask));
578
579 /****************************************************************************/
580 /**
581 *
582 * This routine returns the Interrupt Status Register.
583 *
584 * @param        InstancePtr is a pointer to the XAxiPmon instance.
585 *
586 * @return       Interrupt Status Register contents
587 *
588 * @note         C-Style signature:
589 *               void XAxiPmon_IntrClear(XAxiPmon *InstancePtr)
590 *
591 *****************************************************************************/
592 #define XAxiPmon_IntrGetStatus(InstancePtr)                                  \
593                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
594                         XAPM_IS_OFFSET);
595
596 /****************************************************************************/
597 /**
598 *
599 * This function enables the Global Clock Counter.
600 *
601 * @param        InstancePtr is a pointer to the XAxiPmon instance.
602 *
603 * @return       None
604 *
605 * @note         C-Style signature:
606 *               void XAxiPmon_EnableGlobalClkCounter(XAxiPmon *InstancePtr)
607 *
608 *****************************************************************************/
609 #define XAxiPmon_EnableGlobalClkCounter(InstancePtr) \
610         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
611                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
612                         XAPM_CTL_OFFSET) | XAPM_CR_GCC_ENABLE_MASK);
613
614 /****************************************************************************/
615 /**
616 *
617 * This function disbles the Global Clock Counter.
618 *
619 * @param        InstancePtr is a pointer to the XAxiPmon instance.
620 *
621 * @return       None
622 *
623 * @note         C-Style signature:
624 *               void XAxiPmon_DisableGlobalClkCounter(XAxiPmon *InstancePtr)
625 *
626 *****************************************************************************/
627 #define XAxiPmon_DisableGlobalClkCounter(InstancePtr) \
628         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
629                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
630                         XAPM_CTL_OFFSET) & ~(XAPM_CR_GCC_ENABLE_MASK));
631
632 /****************************************************************************/
633 /**
634 *
635 * This function enables the specified flag in Flag Control Register.
636 *
637 * @param        InstancePtr is a pointer to the XAxiPmon instance.
638 * @param        Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h
639 *
640 * @return       None
641 *
642 * @note         C-Style signature:
643 *               void XAxiPmon_EnableFlag(XAxiPmon *InstancePtr)
644 *
645 *****************************************************************************/
646 #define XAxiPmon_EnableFlag(InstancePtr, Flag) \
647         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_FEC_OFFSET, \
648                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
649                         XAPM_FEC_OFFSET) | (Flag));
650
651 /****************************************************************************/
652 /**
653 *
654 * This function disables the specified flag in Flag Control Register.
655 *
656 * @param        InstancePtr is a pointer to the XAxiPmon instance.
657 * @param        Flag is one of the XAPM_FLAG_* masks defined in xaxipmon.h*
658 * @return       None
659 *
660 * @note         C-Style signature:
661 *               void XAxiPmon_DisableFlag(XAxiPmon *InstancePtr)
662 *
663 *****************************************************************************/
664 #define XAxiPmon_DisableFlag(InstancePtr, Flag) \
665         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_FEC_OFFSET, \
666                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
667                         XAPM_FEC_OFFSET) & ~(Flag));
668
669 /****************************************************************************/
670 /**
671 *
672 * This function loads the sample interval register value into the sample
673 * interval counter.
674 *
675 * @param        InstancePtr is a pointer to the XAxiPmon instance.
676 *
677 * @return       None
678 *
679 * @note         C-Style signature:
680 *               void XAxiPmon_LoadSampleIntervalCounter(XAxiPmon *InstancePtr)
681 *
682 *****************************************************************************/
683 #define XAxiPmon_LoadSampleIntervalCounter(InstancePtr) \
684        XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
685                                                         XAPM_SICR_LOAD_MASK);
686
687
688
689 /****************************************************************************/
690 /**
691 *
692 * This enables the down count of the sample interval counter.
693 *
694 * @param        InstancePtr is a pointer to the XAxiPmon instance.
695 *
696 * @return       None
697 *
698 * @note         C-Style signature:
699 *          void XAxiPmon_EnableSampleIntervalCounter(XAxiPmon *InstancePtr)
700 *
701 *****************************************************************************/
702 #define XAxiPmon_EnableSampleIntervalCounter(InstancePtr) \
703         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
704                                                         XAPM_SICR_ENABLE_MASK);
705
706
707 /****************************************************************************/
708 /**
709 *
710 * This disables the down count of the sample interval counter.
711 *
712 * @param        InstancePtr is a pointer to the XAxiPmon instance.
713 *
714 * @return       None
715 *
716 * @note         C-Style signature:
717 *           void XAxiPmon_DisableSampleIntervalCounter(XAxiPmon *InstancePtr)
718 *
719 *****************************************************************************/
720 #define XAxiPmon_DisableSampleIntervalCounter(InstancePtr) \
721         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
722                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
723                         XAPM_SICR_OFFSET) & ~(XAPM_SICR_ENABLE_MASK));
724
725 /****************************************************************************/
726 /**
727 *
728 * This enables Reset of Metric Counters when Sample Interval Counter lapses.
729 *
730 * @param        InstancePtr is a pointer to the XAxiPmon instance.
731 *
732 * @return       None
733 *
734 * @note         C-Style signature:
735 *               void XAxiPmon_EnableMetricCounterReset(XAxiPmon *InstancePtr)
736 *
737 *****************************************************************************/
738 #define XAxiPmon_EnableMetricCounterReset(InstancePtr) \
739         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET,\
740                                                 XAPM_SICR_MCNTR_RST_MASK);
741
742 /****************************************************************************/
743 /**
744 *
745 * This disables the down count of the sample interval counter.
746 *
747 * @param        InstancePtr is a pointer to the XAxiPmon instance.
748 *
749 * @return       None
750 *
751 * @note         C-Style signature:
752 *               void XAxiPmon_DisableMetricCounterReset(XAxiPmon *InstancePtr)
753 *
754 *****************************************************************************/
755 #define XAxiPmon_DisableMetricCounterReset(InstancePtr) \
756        XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_SICR_OFFSET, \
757                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
758                         XAPM_SICR_OFFSET) & ~(XAPM_SICR_MCNTR_RST_MASK));
759
760 /****************************************************************************/
761 /**
762 *
763 * This function enables the ID Filter Masking.
764 *
765 * @param        InstancePtr is a pointer to the XAxiPmon instance.
766 *
767 * @return       None
768 *
769 * @note         C-Style signature:
770 *               void XAxiPmon_EnableIDFilter(XAxiPmon *InstancePtr)
771 *
772 *****************************************************************************/
773 #define XAxiPmon_EnableIDFilter(InstancePtr) \
774         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
775                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
776                         XAPM_CTL_OFFSET) | XAPM_CR_IDFILTER_ENABLE_MASK);
777
778 /****************************************************************************/
779 /**
780 *
781 * This function disbles the ID Filter masking.
782 *
783 * @param        InstancePtr is a pointer to the XAxiPmon instance.
784 *
785 * @return       None
786 *
787 * @note         C-Style signature:
788 *               void XAxiPmon_DisableIDFilter(XAxiPmon *InstancePtr)
789 *
790 *****************************************************************************/
791 #define XAxiPmon_DisableIDFilter(InstancePtr) \
792         XAxiPmon_WriteReg((InstancePtr)->Config.BaseAddress, XAPM_CTL_OFFSET, \
793                         XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, \
794                         XAPM_CTL_OFFSET) & ~(XAPM_CR_IDFILTER_ENABLE_MASK));
795
796 /****************************************************************************/
797 /**
798 *
799 * This function samples Metric Counters to Sampled Metric Counters by
800 * reading Sample Register and also returns interval. i.e. the number of
801 * clocks in between previous read to the current read of sample register.
802 *
803 * @param        InstancePtr is a pointer to the XAxiPmon instance.
804 *
805 * @return       Interval. i.e. the number of clocks in between previous
806 *               read to the current read of sample register.
807 *
808 * @note         C-Style signature:
809 *               u32 XAxiPmon_SampleMetrics(XAxiPmon *InstancePtr)
810 *
811 *****************************************************************************/
812 #define XAxiPmon_SampleMetrics(InstancePtr) \
813        XAxiPmon_ReadReg((InstancePtr)->Config.BaseAddress, XAPM_SR_OFFSET);
814
815
816 /************************** Function Prototypes *****************************/
817
818 /**
819  * Functions in xaxipmon_sinit.c
820  */
821 XAxiPmon_Config *XAxiPmon_LookupConfig(u16 DeviceId);
822
823 /**
824  * Functions in xaxipmon.c
825  */
826 s32 XAxiPmon_CfgInitialize(XAxiPmon *InstancePtr,
827                 XAxiPmon_Config *ConfigPtr, UINTPTR EffectiveAddr);
828
829 s32 XAxiPmon_ResetMetricCounter(XAxiPmon *InstancePtr);
830
831 void XAxiPmon_ResetGlobalClkCounter(XAxiPmon *InstancePtr);
832
833 s32 XAxiPmon_ResetFifo(XAxiPmon *InstancePtr);
834
835 void XAxiPmon_SetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
836                                         u16 RangeUpper, u16 RangeLower);
837
838 void XAxiPmon_GetIncrementerRange(XAxiPmon *InstancePtr, u8 IncrementerNum,
839                                 u16 *RangeUpper, u16 *RangeLower);
840
841 void XAxiPmon_SetSampleInterval(XAxiPmon *InstancePtr, u32 SampleInterval);
842
843 void XAxiPmon_GetSampleInterval(XAxiPmon *InstancePtr, u32 *SampleInterval);
844
845 s32 XAxiPmon_SetMetrics(XAxiPmon *InstancePtr, u8 Slot, u8 Metrics,
846                                                         u8 CounterNum);
847
848 s32 XAxiPmon_GetMetrics(XAxiPmon *InstancePtr, u8 CounterNum, u8 *Metrics,
849                                                                 u8 *Slot);
850 void XAxiPmon_GetGlobalClkCounter(XAxiPmon *InstancePtr,u32 *CntHighValue,
851                                                         u32 *CntLowValue);
852
853 u32 XAxiPmon_GetMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
854
855 u32 XAxiPmon_GetSampledMetricCounter(XAxiPmon *InstancePtr, u32 CounterNum);
856
857 u32 XAxiPmon_GetIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
858
859 u32 XAxiPmon_GetSampledIncrementer(XAxiPmon *InstancePtr, u32 IncrementerNum);
860
861 void XAxiPmon_SetSwDataReg(XAxiPmon *InstancePtr, u32 SwData);
862
863 u32 XAxiPmon_GetSwDataReg(XAxiPmon *InstancePtr);
864
865 s32 XAxiPmon_StartEventLog(XAxiPmon *InstancePtr, u32 FlagEnables);
866
867 s32 XAxiPmon_StopEventLog(XAxiPmon *InstancePtr);
868
869 s32 XAxiPmon_StartCounters(XAxiPmon *InstancePtr, u32 SampleInterval);
870
871 s32 XAxiPmon_StopCounters(XAxiPmon *InstancePtr);
872
873 void XAxiPmon_EnableMetricsCounter(XAxiPmon *InstancePtr);
874
875 void XAxiPmon_DisableMetricsCounter(XAxiPmon *InstancePtr);
876
877 void XAxiPmon_SetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
878                                         u16 RangeUpper, u16 RangeLower);
879
880 void XAxiPmon_GetLogEnableRanges(XAxiPmon *InstancePtr, u32 CounterNum,
881                                         u16 *RangeUpper, u16 *RangeLower);
882
883 void XAxiPmon_EnableEventLog(XAxiPmon *InstancePtr);
884
885 void XAxiPmon_EnableMetricCounterTrigger(XAxiPmon *InstancePtr);
886
887 void XAxiPmon_DisableMetricCounterTrigger(XAxiPmon *InstancePtr);
888
889 void XAxiPmon_EnableEventLogTrigger(XAxiPmon *InstancePtr);
890
891 void XAxiPmon_DisableEventLogTrigger(XAxiPmon *InstancePtr);
892
893 const char * XAxiPmon_GetMetricName(u8 Metrics);
894
895 void XAxiPmon_SetWriteId(XAxiPmon *InstancePtr, u32 WriteId);
896
897 void XAxiPmon_SetReadId(XAxiPmon *InstancePtr, u32 ReadId);
898
899 u32 XAxiPmon_GetWriteId(XAxiPmon *InstancePtr);
900
901 u32 XAxiPmon_GetReadId(XAxiPmon *InstancePtr);
902
903 void XAxiPmon_SetWrLatencyStart(XAxiPmon *InstancePtr, u8 Param);
904
905 void XAxiPmon_SetWrLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
906
907 void XAxiPmon_SetRdLatencyStart(XAxiPmon *InstancePtr, u8 Param);
908
909 void XAxiPmon_SetRdLatencyEnd(XAxiPmon *InstancePtr, u8 Param);
910
911 u8 XAxiPmon_GetWrLatencyStart(XAxiPmon *InstancePtr);
912
913 u8 XAxiPmon_GetWrLatencyEnd(XAxiPmon *InstancePtr);
914
915 u8 XAxiPmon_GetRdLatencyStart(XAxiPmon *InstancePtr);
916
917 u8 XAxiPmon_GetRdLatencyEnd(XAxiPmon *InstancePtr);
918
919 void XAxiPmon_SetWriteIdMask(XAxiPmon *InstancePtr, u32 WrMask);
920
921 void XAxiPmon_SetReadIdMask(XAxiPmon *InstancePtr, u32 RdMask);
922
923 u32 XAxiPmon_GetWriteIdMask(XAxiPmon *InstancePtr);
924
925 u32 XAxiPmon_GetReadIdMask(XAxiPmon *InstancePtr);
926
927
928 /**
929  * Functions in xaxipmon_selftest.c
930  */
931 s32 XAxiPmon_SelfTest(XAxiPmon *InstancePtr);
932
933 #ifdef __cplusplus
934 }
935 #endif
936
937 #endif  /* End of protection macro. */
938 /** @} */