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