blob: 48309bed82e5b4f927db1d2875996fc340570e84 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13/*
14per-axi
15DESCRIPTION
16Functions related to AXI bus performance counter manipulations.
17*/
18
19#include <linux/io.h>
20#include <linux/err.h>
21#include <linux/init.h>
22#include <linux/platform_device.h>
23#include <linux/proc_fs.h>
24#include "asm/uaccess.h"
25#include "per-axi.h"
26#include "perf.h"
27
28/*
29Definitions for AXI register addresses, macros to set and get register values
30*/
31#define AXI_BASE_SIZE 0x00004000
32#define AXI_REG_BASE (AXI_BASE + 0x00000000)
33#define AXI_REG_BASE_PHYS 0xa8200000
34
35#define __inpdw(port) ioread32(port)
36#define in_dword_masked(addr, mask) (__inpdw(addr) & (mask))
37#define __outpdw(port, val) (iowrite32((uint32_t) (val), port))
38#define out_dword(addr, val) __outpdw(addr, val)
39
40#define HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_ADDR \
41 (AXI_REG_BASE + 0x00003434)
42#define HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_RMSK 0xffff
43#define HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_IN \
44 in_dword_masked(HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_ADDR, \
45 HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_RMSK)
46
47#define HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_ADDR (AXI_REG_BASE + 0x00003438)
48#define HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_RMSK 0xffff
49#define HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_IN \
50 in_dword_masked(HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_ADDR, \
51 HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_RMSK)
52
53#define HWIO_AXI_MONITOR_SELECTION_REG0_ADDR (AXI_REG_BASE + 0x00003428)
54#define HWIO_AXI_MONITOR_SELECTION_REG1_ADDR (AXI_REG_BASE + 0x0000342c)
55#define HWIO_AXI_MONITOR_TENURE_SELECTION_REG_ADDR (AXI_REG_BASE + 0x00003430)
56#define HWIO_AXI_MONITOR_SELECTION_REG0_ETC_BMSK 0x4000
57#define HWIO_AXI_MONITOR_SELECTION_REG0_ECC_BMSK 0x2000
58#define HWIO_AXI_MONITOR_SELECTION_REG0_EEC1_BMSK 0x800
59#define HWIO_AXI_MONITOR_SELECTION_REG0_EEC0_BMSK 0x200
60#define HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_OUT(v) \
61 out_dword(HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_ADDR, v)
62#define HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_OUT(v) \
63 out_dword(HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_ADDR, v)
64#define HWIO_AXI_MONITOR_SELECTION_REG0_OUT(v) \
65 out_dword(HWIO_AXI_MONITOR_SELECTION_REG0_ADDR, v)
66#define HWIO_AXI_MONITOR_SELECTION_REG1_OUT(v) \
67 out_dword(HWIO_AXI_MONITOR_SELECTION_REG1_ADDR, v)
68#define HWIO_AXI_MONITOR_TENURE_SELECTION_REG_OUT(v) \
69 out_dword(HWIO_AXI_MONITOR_TENURE_SELECTION_REG_ADDR, v)
70#define HWIO_AXI_MONITOR_SELECTION_REG0_RMSK 0xffff
71#define HWIO_AXI_MONITOR_SELECTION_REG0_IN \
72 in_dword_masked(HWIO_AXI_MONITOR_SELECTION_REG0_ADDR, \
73 HWIO_AXI_MONITOR_SELECTION_REG0_RMSK)
74
75#define HWIO_AXI_CONFIGURATION_REG_ADDR (AXI_REG_BASE + 0x00000008)
76#define HWIO_AXI_CONFIGURATION_REG_OUT(v) \
77 out_dword(HWIO_AXI_CONFIGURATION_REG_ADDR, v)
78#define HWIO_AXI_CONFIGURATION_REG_PPDM_BMSK 0x0
79#define HWIO_AXI_CONFIGURATION_REG_DISABLE 0x2
80#define AXI_EVTSEL_ENABLE_MASK 0x6a00
81#define AXI_EVTSEL_DISABLE_MASK 0x95ff
82#define AXI_EVTSEL_RESET_MASK 0xfe40
83
84#define HWIO_AXI_MONITOR_EVENT_LOWER_REG0_ADDR (AXI_REG_BASE + 0x00003450)
85#define HWIO_AXI_MONITOR_EVENT_LOWER_REG0_RMSK 0xffff
86#define HWIO_AXI_MONITOR_EVENT_LOWER_REG0_SHFT 0
87#define HWIO_AXI_MONITOR_EVENT_LOWER_REG0_IN \
88 in_dword_masked(HWIO_AXI_MONITOR_EVENT_LOWER_REG0_ADDR, \
89 HWIO_AXI_MONITOR_EVENT_LOWER_REG0_RMSK)
90#define HWIO_AXI_MONITOR_EVENT_UPPER_REG0_ADDR (AXI_REG_BASE + 0x00003454)
91#define HWIO_AXI_MONITOR_EVENT_UPPER_REG0_RMSK 0xffff
92#define HWIO_AXI_MONITOR_EVENT_UPPER_REG0_SHFT 0
93#define HWIO_AXI_MONITOR_EVENT_UPPER_REG0_IN \
94 in_dword_masked(HWIO_AXI_MONITOR_EVENT_UPPER_REG0_ADDR, \
95 HWIO_AXI_MONITOR_EVENT_UPPER_REG0_RMSK)
96
97#define HWIO_AXI_MONITOR_EVENT_LOWER_REG1_ADDR (AXI_REG_BASE + 0x00003458)
98#define HWIO_AXI_MONITOR_EVENT_LOWER_REG1_RMSK 0xffff
99#define HWIO_AXI_MONITOR_EVENT_LOWER_REG1_SHFT 0
100#define HWIO_AXI_MONITOR_EVENT_LOWER_REG1_IN \
101 in_dword_masked(HWIO_AXI_MONITOR_EVENT_LOWER_REG1_ADDR, \
102 HWIO_AXI_MONITOR_EVENT_LOWER_REG1_RMSK)
103#define HWIO_AXI_MONITOR_EVENT_UPPER_REG1_ADDR (AXI_REG_BASE + 0x0000345c)
104#define HWIO_AXI_MONITOR_EVENT_UPPER_REG1_RMSK 0xffff
105#define HWIO_AXI_MONITOR_EVENT_UPPER_REG1_SHFT 0
106#define HWIO_AXI_MONITOR_EVENT_UPPER_REG1_IN \
107 in_dword_masked(HWIO_AXI_MONITOR_EVENT_UPPER_REG1_ADDR, \
108 HWIO_AXI_MONITOR_EVENT_UPPER_REG1_RMSK)
109
110#define HWIO_AXI_MONITOR_TENURE_LOWER_REG_ADDR (AXI_REG_BASE + 0x00003448)
111#define HWIO_AXI_MONITOR_TENURE_LOWER_REG_RMSK 0xffff
112#define HWIO_AXI_MONITOR_TENURE_LOWER_REG_SHFT 0
113#define HWIO_AXI_MONITOR_TENURE_LOWER_REG_IN \
114 in_dword_masked(HWIO_AXI_MONITOR_TENURE_LOWER_REG_ADDR, \
115 HWIO_AXI_MONITOR_TENURE_LOWER_REG_RMSK)
116#define HWIO_AXI_MONITOR_TENURE_UPPER_REG_ADDR (AXI_REG_BASE + 0x00003444)
117#define HWIO_AXI_MONITOR_TENURE_UPPER_REG_RMSK 0xffff
118#define HWIO_AXI_MONITOR_TENURE_UPPER_REG_SHFT 0
119#define HWIO_AXI_MONITOR_TENURE_UPPER_REG_IN \
120 in_dword_masked(HWIO_AXI_MONITOR_TENURE_UPPER_REG_ADDR, \
121 HWIO_AXI_MONITOR_TENURE_UPPER_REG_RMSK)
122
123#define HWIO_AXI_MONITOR_MIN_REG_ADDR (AXI_REG_BASE + 0x0000343c)
124#define HWIO_AXI_MONITOR_MIN_REG_RMSK 0xffff
125#define HWIO_AXI_MONITOR_MIN_REG_SHFT 0
126#define HWIO_AXI_MONITOR_MIN_REG_IN \
127 in_dword_masked(HWIO_AXI_MONITOR_MIN_REG_ADDR, \
128 HWIO_AXI_MONITOR_MIN_REG_RMSK)
129#define HWIO_AXI_MONITOR_MAX_REG_ADDR (AXI_REG_BASE + 0x00003440)
130#define HWIO_AXI_MONITOR_MAX_REG_RMSK 0xffff
131#define HWIO_AXI_MONITOR_MAX_REG_SHFT 0
132#define HWIO_AXI_MONITOR_MAX_REG_IN \
133 in_dword_masked(HWIO_AXI_MONITOR_MAX_REG_ADDR, \
134 HWIO_AXI_MONITOR_MAX_REG_RMSK)
135#define HWIO_AXI_MONITOR_LAST_TENURE_REG_ADDR (AXI_REG_BASE + 0x0000344c)
136#define HWIO_AXI_MONITOR_LAST_TENURE_REG_RMSK 0xffff
137#define HWIO_AXI_MONITOR_LAST_TENURE_REG_SHFT 0
138#define HWIO_AXI_MONITOR_LAST_TENURE_REG_IN \
139 in_dword_masked(HWIO_AXI_MONITOR_LAST_TENURE_REG_ADDR, \
140 HWIO_AXI_MONITOR_LAST_TENURE_REG_RMSK)
141#define HWIO_AXI_MONITOR_TENURE_UPPER_REG_OUT(v) \
142 out_dword(HWIO_AXI_MONITOR_TENURE_UPPER_REG_ADDR, v)
143#define HWIO_AXI_MONITOR_TENURE_LOWER_REG_OUT(v) \
144 out_dword(HWIO_AXI_MONITOR_TENURE_LOWER_REG_ADDR, v)
145
146#define HWIO_AXI_RESET_ALL 0x9400
147#define HWIO_AXI_ENABLE_ALL_NOCYCLES 0x4a00
148#define HWIO_AXI_DISABLE_ALL 0xb500
149uint32_t AXI_BASE;
150
151unsigned int is_first = 1;
152struct perf_mon_axi_data pm_axi_info;
153struct perf_mon_axi_cnts axi_cnts;
154
155/*
156FUNCTION get_axi_sel_reg0
157
158DESCRIPTION
159 Retrieve the value of AXI_SEL_REG0
160
161DEPENDENCIES
162
163RETURN VALUE
164 AXI_SEL_REG0
165SIDE EFFECTS
166*/
167unsigned long get_axi_sel_reg0(void)
168{
169 return pm_axi_info.sel_reg0;
170}
171
172/*
173FUNCTION get_axi_sel_reg1
174
175DESCRIPTION
176 Retrieve the value of AXI_SEL_REG1
177
178DEPENDENCIES
179
180RETURN VALUE
181 AXI_SEL_REG1
182SIDE EFFECTS
183*/
184unsigned long get_axi_sel_reg1(void)
185{
186 return pm_axi_info.sel_reg1;
187}
188
189/*
190FUNCTION get_axi_ten_sel_reg
191
192DESCRIPTION
193 Retrieve the value of AXI_TEN_REG
194
195DEPENDENCIES
196
197RETURN VALUE
198 AXI_TEN_REG
199SIDE EFFECTS
200*/
201unsigned long get_axi_ten_sel_reg(void)
202{
203 return pm_axi_info.ten_sel_reg;
204}
205
206/*
207FUNCTION get_axi_valid
208
209DESCRIPTION
210 Retrieve the value of AXI valid bit
211
212DEPENDENCIES
213
214RETURN VALUE
215 AXI Valid bit
216SIDE EFFECTS
217*/
218unsigned long get_axi_valid(void)
219{
220 return pm_axi_info.valid;
221}
222
223/*
224FUNCTION get_axi_enable
225
226DESCRIPTION
227 Retrieve the value of AXI enable bit
228
229DEPENDENCIES
230
231RETURN VALUE
232 AXI enable bit
233SIDE EFFECTS
234*/
235unsigned long get_axi_enable(void)
236{
237 return pm_axi_info.enable;
238}
239
240/*
241FUNCTION get_axi_clear
242
243DESCRIPTION
244 Retrieve the value of AXI clear bit
245
246DEPENDENCIES
247
248RETURN VALUE
249 AXI clear bit
250SIDE EFFECTS
251*/
252unsigned long get_axi_clear(void)
253{
254 return pm_axi_info.clear;
255}
256
257/*
258FUNCTION pm_axi_cnts_write
259
260DESCRIPTION
261 Write handler for the /proc axi results directory.
262
263DEPENDENCIES
264
265RETURN VALUE
266 Number of characters to output.
267
268SIDE EFFECTS
269*/
270int pm_axi_cnts_write(struct file *file, const char *buff,
271 unsigned long cnt, void *data)
272{
273 char *newbuf;
274 struct PerfMonAxiCnts *p =
275 (struct PerfMonAxiCnts *)data;
276
277 if (p == 0)
278 return cnt;
279 /*
280 * Alloc the user data in kernel space. and then copy user to kernel
281 */
282 newbuf = kmalloc(cnt + 1, GFP_KERNEL);
283 if (0 == newbuf)
284 return cnt;
285 if (copy_from_user(newbuf, buff, cnt) != 0) {
286 printk(KERN_INFO "%s copy_from_user failed\n", __func__);
287 return cnt;
288 }
289 return cnt;
290}
291
292/*
293FUNCTION pm_axi_update_cnts
294
295DESCRIPTION
296 Read the current AXI counter values. Check for overflows and
297 adjust the values stored accordingly.
298
299DEPENDENCIES
300
301RETURN VALUE
302
303SIDE EFFECTS
304*/
305void pm_axi_update_cnts(void)
306{
307 if (is_first) {
308 pm_axi_start();
309 } else {
310 if (pm_axi_info.valid == 1) {
311 pm_axi_info.valid = 0;
312 pm_axi_update();
313 } else {
314 pm_axi_enable();
315 }
316 }
317 is_first = 0;
318 axi_cnts.cycles += pm_get_axi_cycle_count();
319 axi_cnts.cnt0 += pm_get_axi_evt0_count();
320 axi_cnts.cnt1 += pm_get_axi_evt1_count();
321 axi_cnts.tenure_total += pm_get_axi_ten_total_count();
322
323 axi_cnts.tenure_min = pm_get_axi_ten_min_count();
324 axi_cnts.tenure_max = pm_get_axi_ten_max_count();
325 axi_cnts.tenure_last = pm_get_axi_ten_last_count();
326
327 pm_axi_start();
328}
329
330/*
331FUNCTION pm_axi_clear_cnts
332
333DESCRIPTION
334 Clear the locally stored AXI counter values.
335 Also clear the AXI counter registers.
336
337DEPENDENCIES
338
339RETURN VALUE
340
341SIDE EFFECTS
342*/
343void pm_axi_clear_cnts(void)
344{
345 axi_cnts.cycles = 0;
346 axi_cnts.cnt0 = 0;
347 axi_cnts.cnt1 = 0;
348 axi_cnts.tenure_total = 0;
349 axi_cnts.tenure_min = 0;
350 axi_cnts.tenure_max = 0;
351 axi_cnts.tenure_last = 0;
352 pm_axi_start();
353}
354
355/*
356FUNCTION pm_axi_read_decimal
357
358DESCRIPTION
359 Read handler for the /proc axi results directory in decimal format.
360
361DEPENDENCIES
362
363RETURN VALUE
364 Number of characters to output.
365
366SIDE EFFECTS
367*/
368int pm_axi_read_decimal(char *page, char **start, off_t off, int count,
369 int *eof, void *data)
370{
371 struct perf_mon_axi_cnts *p = (struct perf_mon_axi_cnts *)data;
372
373 return sprintf(page, "cnt0:%llu cnt1:%llu tenure:%llu ten_max:%llu \
374 ten_min:%llu ten_last:%llu cycles:%llu\n",
375 p->cnt0,
376 p->cnt1,
377 p->tenure_total,
378 p->tenure_max,
379 p->tenure_min,
380 p->tenure_last,
381 p->cycles);
382}
383
384/*
385FUNCTION pm_axi_read_hex
386
387DESCRIPTION
388 Read handler for the /proc axi results directory in hex format.
389
390DEPENDENCIES
391
392RETURN VALUE
393 Number of characters to output.
394
395SIDE EFFECTS
396*/
397int pm_axi_read_hex(char *page, char **start, off_t off, int count,
398 int *eof, void *data)
399{
400 struct perf_mon_axi_cnts *p = (struct perf_mon_axi_cnts *)data;
401
402 return sprintf(page, "cnt0:%llx cnt1:%llx tenure:%llx ten_max:%llx \
403 ten_min:%llx ten_last:%llx cycles:%llx\n",
404 p->cnt0,
405 p->cnt1,
406 p->tenure_total,
407 p->tenure_max,
408 p->tenure_min,
409 p->tenure_last,
410 p->cycles);
411
412}
413
414/*
415FUNCTION pm_axi_set_proc_entry
416
417DESCRIPTION
418 Create a generic entry for the /proc axi settings directory.
419
420DEPENDENCIES
421
422RETURN VALUE
423
424SIDE EFFECTS
425*/
426void pm_axi_set_proc_entry(char *name, unsigned long *var,
427 struct proc_dir_entry *d, int hex)
428{
429 struct proc_dir_entry *pe;
430 pe = create_proc_entry(name, 0777, d);
431 if (0 == pe)
432 return;
433 if (hex) {
434 pe->read_proc = per_process_read;
435 pe->write_proc = per_process_write_hex;
436 } else {
437 pe->read_proc = per_process_read_decimal;
438 pe->write_proc = per_process_write_dec;
439 }
440 pe->data = (void *)var;
441}
442
443/*
444FUNCTION pm_axi_get_cnt_proc_entry
445
446DESCRIPTION
447 Create a generic entry for the /proc axi results directory.
448
449DEPENDENCIES
450
451RETURN VALUE
452
453SIDE EFFECTS
454*/
455void pm_axi_get_cnt_proc_entry(char *name, struct perf_mon_axi_cnts *var,
456 struct proc_dir_entry *d, int hex)
457{
458 struct proc_dir_entry *pe;
459 pe = create_proc_entry(name, 0777, d);
460 if (0 == pe)
461 return;
462 if (hex) {
463 pe->read_proc = pm_axi_read_hex;
464 pe->write_proc = pm_axi_cnts_write;
465 } else {
466 pe->read_proc = pm_axi_read_decimal;
467 pe->write_proc = pm_axi_cnts_write;
468 }
469 pe->data = (void *)var;
470}
471
472/*
473FUNCTION pm_axi_clear_tenure
474
475DESCRIPTION
476 Clear AXI tenure cntr manually. Temporary solution till hardware bug
477 is fixed
478
479DEPENDENCIES
480
481RETURN VALUE
482
483SIDE EFFECTS
484*/
485void pm_axi_clear_tenure(void)
486{
487 HWIO_AXI_MONITOR_TENURE_UPPER_REG_OUT(0x0);
488 HWIO_AXI_MONITOR_TENURE_LOWER_REG_OUT(0x0);
489}
490
491/*
492FUNCTION pm_axi_init
493
494DESCRIPTION
495 Map AXI region to virtual memory.
496
497DEPENDENCIES
498
499RETURN VALUE
500
501SIDE EFFECTS
502*/
503void pm_axi_init()
504{
505 /*Map the AXI regs*/
506 #ifdef CONFIG_ARCH_QSD8X50
507 {
508 /*Map the AXI regs*/
509 AXI_BASE = (uint32_t)ioremap(AXI_REG_BASE_PHYS, AXI_BASE_SIZE);
510 if (!AXI_BASE)
511 printk(KERN_ERR "Mem map failed\n");
512 }
513 #else
514 {
515 AXI_BASE = (uint32_t)kmalloc(AXI_BASE_SIZE, GFP_KERNEL);
516 }
517 #endif
518
519}
520
521/*
522FUNCTION pm_axi_start
523
524DESCRIPTION
525 Set event0, event1 and tenure registers based on the /proc entries.
526 Set cycle cntr to fffffffe to start counters.
527
528DEPENDENCIES
529
530RETURN VALUE
531
532SIDE EFFECTS
533*/
534void
535pm_axi_start()
536{
537 unsigned long sel_reg0, sel_reg1, ten_sel_reg;
538 sel_reg0 = get_axi_sel_reg0();
539 sel_reg1 = get_axi_sel_reg1();
540 ten_sel_reg = get_axi_ten_sel_reg();
541 HWIO_AXI_CONFIGURATION_REG_OUT(HWIO_AXI_CONFIGURATION_REG_PPDM_BMSK);
542 /*Set AXI Cycle Counter to enable AXI Monitors*/
543 HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_OUT(0xffff);
544 HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_OUT(0xfffe);
545 /*Set master/slave*/
546 HWIO_AXI_MONITOR_SELECTION_REG1_OUT(sel_reg1);
547 HWIO_AXI_MONITOR_SELECTION_REG0_OUT(HWIO_AXI_RESET_ALL);
548 HWIO_AXI_MONITOR_SELECTION_REG0_OUT(HWIO_AXI_ENABLE_ALL_NOCYCLES);
549 HWIO_AXI_MONITOR_SELECTION_REG0_OUT(HWIO_AXI_MONITOR_SELECTION_REG0_IN
550 | sel_reg0);
551 HWIO_AXI_MONITOR_SELECTION_REG0_OUT(HWIO_AXI_MONITOR_SELECTION_REG0_IN
552 | HWIO_AXI_MONITOR_SELECTION_REG0_ECC_BMSK);
553 HWIO_AXI_CONFIGURATION_REG_OUT(HWIO_AXI_CONFIGURATION_REG_PPDM_BMSK);
554}
555
556/*
557FUNCTION pm_axi_update
558
559DESCRIPTION
560 Set event0, event1 and tenure registers based on the /proc entries.
561
562DEPENDENCIES
563
564RETURN VALUE
565
566SIDE EFFECTS
567*/
568void
569pm_axi_update()
570{
571 HWIO_AXI_CONFIGURATION_REG_OUT(HWIO_AXI_CONFIGURATION_REG_PPDM_BMSK);
572 HWIO_AXI_MONITOR_SELECTION_REG0_OUT(HWIO_AXI_MONITOR_SELECTION_REG0_IN
573 | HWIO_AXI_RESET_ALL);
574 HWIO_AXI_MONITOR_SELECTION_REG0_OUT(HWIO_AXI_MONITOR_SELECTION_REG0_IN
575 & HWIO_AXI_DISABLE_ALL);
576 pm_axi_start();
577}
578
579/*
580FUNCTION pm_axi_disable
581
582DESCRIPTION
583 Disable all cntrs.
584
585DEPENDENCIES
586
587RETURN VALUE
588
589SIDE EFFECTS
590*/
591void
592pm_axi_disable(void)
593{
594 unsigned long sel_reg0;
595 /*Disable cntrs*/
596 sel_reg0 = get_axi_sel_reg0();
597 HWIO_AXI_MONITOR_SELECTION_REG0_OUT(sel_reg0 & AXI_EVTSEL_DISABLE_MASK);
598 /*Disable clk*/
599 HWIO_AXI_CONFIGURATION_REG_OUT(HWIO_AXI_CONFIGURATION_REG_DISABLE);
600}
601
602/*
603FUNCTION pm_axi_enable
604
605DESCRIPTION
606 Enable all cntrs.
607
608DEPENDENCIES
609
610RETURN VALUE
611
612SIDE EFFECTS
613*/
614void
615pm_axi_enable(void)
616{
617 unsigned long sel_reg0;
618 /*Enable cntrs*/
619 sel_reg0 = get_axi_sel_reg0();
620 HWIO_AXI_MONITOR_SELECTION_REG0_OUT(sel_reg0 | 0x6a00);
621 /*Enable clk*/
622 HWIO_AXI_CONFIGURATION_REG_OUT(HWIO_AXI_CONFIGURATION_REG_PPDM_BMSK);
623}
624
625/*
626FUNCTION pm_axi_disable_cnts
627
628DESCRIPTION
629 Read cycle cntr value
630
631DEPENDENCIES
632
633RETURN VALUE
634
635SIDE EFFECTS
636*/
637unsigned long
638pm_get_axi_cycle_count(void)
639{
640 if (HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_IN == 0x0 &&
641 HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_IN == 0x0) {
642 /*Set AXI Cycle Counter to enable AXI Monitors*/
643 HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_OUT(0xffff);
644 HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_OUT(0xfffe);
645 }
646 return 0xfffffffe - ((HWIO_AXI_MONITOR_CYCLE_COUNT_UPPER_REG_IN << 16)
647 + HWIO_AXI_MONITOR_CYCLE_COUNT_LOWER_REG_IN);
648}
649
650/*
651FUNCTION pm_get_axi_evt0_count
652
653DESCRIPTION
654 Read Event0 cntr value
655
656DEPENDENCIES
657
658RETURN VALUE
659
660SIDE EFFECTS
661*/
662unsigned long
663pm_get_axi_evt0_count(void)
664{
665 return (HWIO_AXI_MONITOR_EVENT_UPPER_REG0_IN << 16)
666 + HWIO_AXI_MONITOR_EVENT_LOWER_REG0_IN;
667}
668
669/*
670FUNCTION pm_get_axi_evt1_count
671
672DESCRIPTION
673 Read Event1 cntr value
674
675DEPENDENCIES
676
677RETURN VALUE
678
679SIDE EFFECTS
680*/
681unsigned long
682pm_get_axi_evt1_count(void)
683{
684 return (HWIO_AXI_MONITOR_EVENT_UPPER_REG1_IN << 16)
685 + HWIO_AXI_MONITOR_EVENT_LOWER_REG1_IN;
686}
687
688/*
689FUNCTION pm_get_axi_ten_min_count
690
691DESCRIPTION
692 Read min tenure cntr value
693
694DEPENDENCIES
695
696RETURN VALUE
697
698SIDE EFFECTS
699*/
700unsigned long
701pm_get_axi_ten_min_count(void)
702{
703 return HWIO_AXI_MONITOR_MIN_REG_IN;
704}
705
706/*
707FUNCTION pm_get_axi_ten_max_count
708
709DESCRIPTION
710 Read max tenure cntr value
711
712DEPENDENCIES
713
714RETURN VALUE
715
716SIDE EFFECTS
717*/
718unsigned long
719pm_get_axi_ten_max_count(void)
720{
721 return HWIO_AXI_MONITOR_MAX_REG_IN;
722}
723
724/*
725FUNCTION pm_get_axi_ten_total_count
726
727DESCRIPTION
728 Read total tenure cntr value
729
730DEPENDENCIES
731
732RETURN VALUE
733
734SIDE EFFECTS
735*/
736unsigned long
737pm_get_axi_ten_total_count(void)
738{
739 return (HWIO_AXI_MONITOR_TENURE_UPPER_REG_IN << 16)
740 + HWIO_AXI_MONITOR_TENURE_LOWER_REG_IN;
741}
742
743/*
744FUNCTION pm_get_axi_ten_last_count
745
746DESCRIPTION
747 Read last tenure cntr value
748
749DEPENDENCIES
750
751RETURN VALUE
752
753SIDE EFFECTS
754*/
755unsigned long
756pm_get_axi_ten_last_count(void)
757{
758 return HWIO_AXI_MONITOR_LAST_TENURE_REG_IN;
759}