blob: f5eeb3fb9d962433665b0a3e429b44ff3e4174a6 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* Copyright (c) 2002,2008-2011, 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
14#include <linux/debugfs.h>
15
16#include "kgsl.h"
17#include "kgsl_device.h"
18
19/*default log levels is error for everything*/
20#define KGSL_LOG_LEVEL_DEFAULT 3
21#define KGSL_LOG_LEVEL_MAX 7
22
23struct dentry *kgsl_debugfs_dir;
24
25static inline int kgsl_log_set(unsigned int *log_val, void *data, u64 val)
26{
27 *log_val = min((unsigned int)val, (unsigned int)KGSL_LOG_LEVEL_MAX);
28 return 0;
29}
30
31#define KGSL_DEBUGFS_LOG(__log) \
32static int __log ## _set(void *data, u64 val) \
33{ \
34 struct kgsl_device *device = data; \
35 return kgsl_log_set(&device->__log, data, val); \
36} \
37static int __log ## _get(void *data, u64 *val) \
38{ \
39 struct kgsl_device *device = data; \
40 *val = device->__log; \
41 return 0; \
42} \
43DEFINE_SIMPLE_ATTRIBUTE(__log ## _fops, \
44__log ## _get, __log ## _set, "%llu\n"); \
45
46KGSL_DEBUGFS_LOG(drv_log);
47KGSL_DEBUGFS_LOG(cmd_log);
48KGSL_DEBUGFS_LOG(ctxt_log);
49KGSL_DEBUGFS_LOG(mem_log);
50KGSL_DEBUGFS_LOG(pwr_log);
51
52void kgsl_device_debugfs_init(struct kgsl_device *device)
53{
54 if (kgsl_debugfs_dir && !IS_ERR(kgsl_debugfs_dir))
55 device->d_debugfs = debugfs_create_dir(device->name,
56 kgsl_debugfs_dir);
57
58 if (!device->d_debugfs || IS_ERR(device->d_debugfs))
59 return;
60
61 device->cmd_log = KGSL_LOG_LEVEL_DEFAULT;
62 device->ctxt_log = KGSL_LOG_LEVEL_DEFAULT;
63 device->drv_log = KGSL_LOG_LEVEL_DEFAULT;
64 device->mem_log = KGSL_LOG_LEVEL_DEFAULT;
65 device->pwr_log = KGSL_LOG_LEVEL_DEFAULT;
66
67 debugfs_create_file("log_level_cmd", 0644, device->d_debugfs, device,
68 &cmd_log_fops);
69 debugfs_create_file("log_level_ctxt", 0644, device->d_debugfs, device,
70 &ctxt_log_fops);
71 debugfs_create_file("log_level_drv", 0644, device->d_debugfs, device,
72 &drv_log_fops);
73 debugfs_create_file("log_level_mem", 0644, device->d_debugfs, device,
74 &mem_log_fops);
75 debugfs_create_file("log_level_pwr", 0644, device->d_debugfs, device,
76 &pwr_log_fops);
77}
78
79void kgsl_core_debugfs_init(void)
80{
81 kgsl_debugfs_dir = debugfs_create_dir("kgsl", 0);
82}
Jordan Croused8f1c6b2011-10-04 09:31:29 -060083
84void kgsl_core_debugfs_close(void)
85{
86 debugfs_remove_recursive(kgsl_debugfs_dir);
87}