1 /**
2 * Copyright (C) ARM Limited 2012-2013. 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 #include "gator_events_mali_common.h"
11 static u32 gator_mali_get_id(void)
12 {
13 return MALI_SUPPORT;
14 }
16 extern const char *gator_mali_get_mali_name(void)
17 {
18 u32 id = gator_mali_get_id();
20 switch (id) {
21 case MALI_T6xx:
22 return "Mali-T6xx";
23 case MALI_4xx:
24 return "Mali-4xx";
25 default:
26 pr_debug("gator: Mali-T6xx: unknown Mali ID (%d)\n", id);
27 return "Mali-Unknown";
28 }
29 }
31 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)
32 {
33 int err;
34 char buf[255];
35 struct dentry *dir;
37 /* If the counter name is empty ignore it */
38 if (strlen(event_name) != 0) {
39 /* Set up the filesystem entry for this event. */
40 snprintf(buf, sizeof(buf), "ARM_%s_%s", mali_name, event_name);
42 dir = gatorfs_mkdir(sb, root, buf);
44 if (dir == NULL) {
45 pr_debug("gator: Mali-T6xx: error creating file system for: %s (%s)", event_name, buf);
46 return -1;
47 }
49 err = gatorfs_create_ulong(sb, dir, "enabled", &counter->enabled);
50 if (err != 0) {
51 pr_debug("gator: Mali-T6xx: error calling gatorfs_create_ulong for: %s (%s)", event_name, buf);
52 return -1;
53 }
54 err = gatorfs_create_ro_ulong(sb, dir, "key", &counter->key);
55 if (err != 0) {
56 pr_debug("gator: Mali-T6xx: error calling gatorfs_create_ro_ulong for: %s (%s)", event_name, buf);
57 return -1;
58 }
59 }
61 return 0;
62 }
64 extern void gator_mali_initialise_counters(mali_counter counters[], unsigned int n_counters)
65 {
66 unsigned int cnt;
68 for (cnt = 0; cnt < n_counters; cnt++) {
69 mali_counter *counter = &counters[cnt];
71 counter->key = gator_events_get_key();
72 counter->enabled = 0;
73 }
74 }