gator: Version 5.19
[firefly-linux-kernel-4.4.55.git] / drivers / gator / gator_events_mali_common.h
1 /**
2  * Copyright (C) ARM Limited 2012-2014. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  */
9
10 #if !defined(GATOR_EVENTS_MALI_COMMON_H)
11 #define GATOR_EVENTS_MALI_COMMON_H
12
13 #include "gator.h"
14
15 #include <linux/module.h>
16 #include <linux/time.h>
17 #include <linux/math64.h>
18 #include <linux/slab.h>
19 #include <asm/io.h>
20
21 /* Ensure that MALI_SUPPORT has been defined to something. */
22 #ifndef MALI_SUPPORT
23 #error MALI_SUPPORT not defined!
24 #endif
25
26 /* Values for the supported activity event types */
27 #define ACTIVITY_START  (1)
28 #define ACTIVITY_STOP   (2)
29
30 /*
31  * Runtime state information for a counter.
32  */
33 typedef struct {
34         // 'key' (a unique id set by gatord and returned by gator.ko)
35         unsigned long key;
36         // counter enable state
37         unsigned long enabled;
38         // for activity counters, the number of cores, otherwise -1
39         unsigned long cores;
40 } mali_counter;
41
42 /*
43  * Mali-4xx
44  */
45 typedef int mali_profiling_set_event_type(unsigned int, int);
46 typedef void mali_profiling_control_type(unsigned int, unsigned int);
47 typedef void mali_profiling_get_counters_type(unsigned int *, unsigned int *, unsigned int *, unsigned int *);
48
49 /*
50  * Driver entry points for functions called directly by gator.
51  */
52 extern int _mali_profiling_set_event(unsigned int, int);
53 extern void _mali_profiling_control(unsigned int, unsigned int);
54 extern void _mali_profiling_get_counters(unsigned int *, unsigned int *, unsigned int *, unsigned int *);
55
56 /**
57  * Creates a filesystem entry under /dev/gator relating to the specified event name and key, and
58  * associate the key/enable values with this entry point.
59  *
60  * @param event_name The name of the event.
61  * @param sb Linux super block
62  * @param root Directory under which the entry will be created.
63  * @param counter_key Ptr to location which will be associated with the counter key.
64  * @param counter_enabled Ptr to location which will be associated with the counter enable state.
65  *
66  * @return 0 if entry point was created, non-zero if not.
67  */
68 extern int gator_mali_create_file_system(const char *mali_name, const char *event_name, struct super_block *sb, struct dentry *root, mali_counter *counter, unsigned long *event);
69
70 /**
71  * Initializes the counter array.
72  *
73  * @param keys The array of counters
74  * @param n_counters The number of entries in each of the arrays.
75  */
76 extern void gator_mali_initialise_counters(mali_counter counters[], unsigned int n_counters);
77
78 #endif /* GATOR_EVENTS_MALI_COMMON_H  */