blob: 34613168445ce380fee6f111d52436fb41b6b6ab [file] [log] [blame]
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -07001/* Copyright (c) 2002,2008-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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/delay.h>
15#include <linux/debugfs.h>
16#include <linux/uaccess.h>
17#include <linux/io.h>
18
19#include "kgsl.h"
20#include "adreno_postmortem.h"
21#include "adreno.h"
22
Jeremy Gebbeneebc4612011-08-31 10:15:21 -070023#include "a2xx_reg.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070024
25unsigned int kgsl_cff_dump_enable;
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -070026int adreno_pm_regs_enabled;
27int adreno_pm_ib_enabled;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070028
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029static struct dentry *pm_d_debugfs;
30
31static int pm_dump_set(void *data, u64 val)
32{
33 struct kgsl_device *device = data;
34
35 if (val) {
36 mutex_lock(&device->mutex);
37 adreno_postmortem_dump(device, 1);
38 mutex_unlock(&device->mutex);
39 }
40
41 return 0;
42}
43
44DEFINE_SIMPLE_ATTRIBUTE(pm_dump_fops,
45 NULL,
46 pm_dump_set, "%llu\n");
47
48static int pm_regs_enabled_set(void *data, u64 val)
49{
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -070050 adreno_pm_regs_enabled = val ? 1 : 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051 return 0;
52}
53
54static int pm_regs_enabled_get(void *data, u64 *val)
55{
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -070056 *val = adreno_pm_regs_enabled;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057 return 0;
58}
59
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -070060static int pm_ib_enabled_set(void *data, u64 val)
61{
62 adreno_pm_ib_enabled = val ? 1 : 0;
63 return 0;
64}
65
66static int pm_ib_enabled_get(void *data, u64 *val)
67{
68 *val = adreno_pm_ib_enabled;
69 return 0;
70}
71
72
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070073DEFINE_SIMPLE_ATTRIBUTE(pm_regs_enabled_fops,
74 pm_regs_enabled_get,
75 pm_regs_enabled_set, "%llu\n");
76
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -070077DEFINE_SIMPLE_ATTRIBUTE(pm_ib_enabled_fops,
78 pm_ib_enabled_get,
79 pm_ib_enabled_set, "%llu\n");
80
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070081
82static int kgsl_cff_dump_enable_set(void *data, u64 val)
83{
84#ifdef CONFIG_MSM_KGSL_CFF_DUMP
85 kgsl_cff_dump_enable = (val != 0);
86 return 0;
87#else
88 return -EINVAL;
89#endif
90}
91
92static int kgsl_cff_dump_enable_get(void *data, u64 *val)
93{
94 *val = kgsl_cff_dump_enable;
95 return 0;
96}
97
98DEFINE_SIMPLE_ATTRIBUTE(kgsl_cff_dump_enable_fops, kgsl_cff_dump_enable_get,
99 kgsl_cff_dump_enable_set, "%llu\n");
100
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700101typedef void (*reg_read_init_t)(struct kgsl_device *device);
102typedef void (*reg_read_fill_t)(struct kgsl_device *device, int i,
103 unsigned int *vals, int linec);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700104
105void adreno_debugfs_init(struct kgsl_device *device)
106{
Ranjhith Kalisamy823c1482011-09-05 20:31:07 +0530107 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
108
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700109 if (!device->d_debugfs || IS_ERR(device->d_debugfs))
110 return;
111
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700112 debugfs_create_file("cff_dump", 0644, device->d_debugfs, device,
113 &kgsl_cff_dump_enable_fops);
Ranjhith Kalisamy823c1482011-09-05 20:31:07 +0530114 debugfs_create_u32("wait_timeout", 0644, device->d_debugfs,
115 &adreno_dev->wait_timeout);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700116
117 /* Create post mortem control files */
118
119 pm_d_debugfs = debugfs_create_dir("postmortem", device->d_debugfs);
120
121 if (IS_ERR(pm_d_debugfs))
122 return;
123
124 debugfs_create_file("dump", 0600, pm_d_debugfs, device,
125 &pm_dump_fops);
126 debugfs_create_file("regs_enabled", 0644, pm_d_debugfs, device,
127 &pm_regs_enabled_fops);
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -0700128 debugfs_create_file("ib_enabled", 0644, pm_d_debugfs, device,
129 &pm_ib_enabled_fops);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700130}