blob: e3c9a18ab958bb4c5b01b7fa53c57a9a901b563b [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
Steve Mucklef132c6c2012-06-06 18:30:57 -070014#include <linux/export.h>
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070015#include <linux/delay.h>
16#include <linux/debugfs.h>
17#include <linux/uaccess.h>
18#include <linux/io.h>
19
20#include "kgsl.h"
21#include "adreno_postmortem.h"
22#include "adreno.h"
23
Jeremy Gebbeneebc4612011-08-31 10:15:21 -070024#include "a2xx_reg.h"
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070025
26unsigned int kgsl_cff_dump_enable;
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -070027int adreno_pm_regs_enabled;
28int adreno_pm_ib_enabled;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070029
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070030static struct dentry *pm_d_debugfs;
31
32static int pm_dump_set(void *data, u64 val)
33{
34 struct kgsl_device *device = data;
35
36 if (val) {
37 mutex_lock(&device->mutex);
38 adreno_postmortem_dump(device, 1);
39 mutex_unlock(&device->mutex);
40 }
41
42 return 0;
43}
44
45DEFINE_SIMPLE_ATTRIBUTE(pm_dump_fops,
46 NULL,
47 pm_dump_set, "%llu\n");
48
49static int pm_regs_enabled_set(void *data, u64 val)
50{
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -070051 adreno_pm_regs_enabled = val ? 1 : 0;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070052 return 0;
53}
54
55static int pm_regs_enabled_get(void *data, u64 *val)
56{
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -070057 *val = adreno_pm_regs_enabled;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070058 return 0;
59}
60
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -070061static int pm_ib_enabled_set(void *data, u64 val)
62{
63 adreno_pm_ib_enabled = val ? 1 : 0;
64 return 0;
65}
66
67static int pm_ib_enabled_get(void *data, u64 *val)
68{
69 *val = adreno_pm_ib_enabled;
70 return 0;
71}
72
73
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070074DEFINE_SIMPLE_ATTRIBUTE(pm_regs_enabled_fops,
75 pm_regs_enabled_get,
76 pm_regs_enabled_set, "%llu\n");
77
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -070078DEFINE_SIMPLE_ATTRIBUTE(pm_ib_enabled_fops,
79 pm_ib_enabled_get,
80 pm_ib_enabled_set, "%llu\n");
81
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070082
83static int kgsl_cff_dump_enable_set(void *data, u64 val)
84{
85#ifdef CONFIG_MSM_KGSL_CFF_DUMP
86 kgsl_cff_dump_enable = (val != 0);
87 return 0;
88#else
89 return -EINVAL;
90#endif
91}
92
93static int kgsl_cff_dump_enable_get(void *data, u64 *val)
94{
95 *val = kgsl_cff_dump_enable;
96 return 0;
97}
98
99DEFINE_SIMPLE_ATTRIBUTE(kgsl_cff_dump_enable_fops, kgsl_cff_dump_enable_get,
100 kgsl_cff_dump_enable_set, "%llu\n");
101
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700102typedef void (*reg_read_init_t)(struct kgsl_device *device);
103typedef void (*reg_read_fill_t)(struct kgsl_device *device, int i,
104 unsigned int *vals, int linec);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700105
106void adreno_debugfs_init(struct kgsl_device *device)
107{
Ranjhith Kalisamy823c1482011-09-05 20:31:07 +0530108 struct adreno_device *adreno_dev = ADRENO_DEVICE(device);
109
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700110 if (!device->d_debugfs || IS_ERR(device->d_debugfs))
111 return;
112
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700113 debugfs_create_file("cff_dump", 0644, device->d_debugfs, device,
114 &kgsl_cff_dump_enable_fops);
Ranjhith Kalisamy823c1482011-09-05 20:31:07 +0530115 debugfs_create_u32("wait_timeout", 0644, device->d_debugfs,
116 &adreno_dev->wait_timeout);
Jeremy Gebbend0ab6ad2012-04-06 11:13:35 -0600117 debugfs_create_u32("ib_check", 0644, device->d_debugfs,
118 &adreno_dev->ib_check_level);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700119
Tarun Karra3335f142012-06-19 14:11:48 -0700120 /* By Default enable fast hang detection */
121 adreno_dev->fast_hang_detect = 1;
122 debugfs_create_u32("fast_hang_detect", 0644, device->d_debugfs,
123 &adreno_dev->fast_hang_detect);
124
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700125 /* Create post mortem control files */
126
127 pm_d_debugfs = debugfs_create_dir("postmortem", device->d_debugfs);
128
129 if (IS_ERR(pm_d_debugfs))
130 return;
131
132 debugfs_create_file("dump", 0600, pm_d_debugfs, device,
133 &pm_dump_fops);
134 debugfs_create_file("regs_enabled", 0644, pm_d_debugfs, device,
135 &pm_regs_enabled_fops);
Harsh Vardhan Dwivediff6dc292012-02-23 16:38:30 -0700136 debugfs_create_file("ib_enabled", 0644, pm_d_debugfs, device,
137 &pm_ib_enabled_fops);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700138}