Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2002,2008-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 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 Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame^] | 14 | #include <linux/export.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 15 | #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 Gebben | eebc461 | 2011-08-31 10:15:21 -0700 | [diff] [blame] | 24 | #include "a2xx_reg.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 25 | |
| 26 | unsigned int kgsl_cff_dump_enable; |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 27 | int adreno_pm_regs_enabled; |
| 28 | int adreno_pm_ib_enabled; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 29 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 30 | static struct dentry *pm_d_debugfs; |
| 31 | |
| 32 | static 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 | |
| 45 | DEFINE_SIMPLE_ATTRIBUTE(pm_dump_fops, |
| 46 | NULL, |
| 47 | pm_dump_set, "%llu\n"); |
| 48 | |
| 49 | static int pm_regs_enabled_set(void *data, u64 val) |
| 50 | { |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 51 | adreno_pm_regs_enabled = val ? 1 : 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | static int pm_regs_enabled_get(void *data, u64 *val) |
| 56 | { |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 57 | *val = adreno_pm_regs_enabled; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 58 | return 0; |
| 59 | } |
| 60 | |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 61 | static int pm_ib_enabled_set(void *data, u64 val) |
| 62 | { |
| 63 | adreno_pm_ib_enabled = val ? 1 : 0; |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | static int pm_ib_enabled_get(void *data, u64 *val) |
| 68 | { |
| 69 | *val = adreno_pm_ib_enabled; |
| 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 74 | DEFINE_SIMPLE_ATTRIBUTE(pm_regs_enabled_fops, |
| 75 | pm_regs_enabled_get, |
| 76 | pm_regs_enabled_set, "%llu\n"); |
| 77 | |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 78 | DEFINE_SIMPLE_ATTRIBUTE(pm_ib_enabled_fops, |
| 79 | pm_ib_enabled_get, |
| 80 | pm_ib_enabled_set, "%llu\n"); |
| 81 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 82 | |
| 83 | static 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 | |
| 93 | static int kgsl_cff_dump_enable_get(void *data, u64 *val) |
| 94 | { |
| 95 | *val = kgsl_cff_dump_enable; |
| 96 | return 0; |
| 97 | } |
| 98 | |
| 99 | DEFINE_SIMPLE_ATTRIBUTE(kgsl_cff_dump_enable_fops, kgsl_cff_dump_enable_get, |
| 100 | kgsl_cff_dump_enable_set, "%llu\n"); |
| 101 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 102 | typedef void (*reg_read_init_t)(struct kgsl_device *device); |
| 103 | typedef void (*reg_read_fill_t)(struct kgsl_device *device, int i, |
| 104 | unsigned int *vals, int linec); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 105 | |
| 106 | void adreno_debugfs_init(struct kgsl_device *device) |
| 107 | { |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 108 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 109 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 110 | if (!device->d_debugfs || IS_ERR(device->d_debugfs)) |
| 111 | return; |
| 112 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 113 | debugfs_create_file("cff_dump", 0644, device->d_debugfs, device, |
| 114 | &kgsl_cff_dump_enable_fops); |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 115 | debugfs_create_u32("wait_timeout", 0644, device->d_debugfs, |
| 116 | &adreno_dev->wait_timeout); |
Jeremy Gebben | d0ab6ad | 2012-04-06 11:13:35 -0600 | [diff] [blame] | 117 | debugfs_create_u32("ib_check", 0644, device->d_debugfs, |
| 118 | &adreno_dev->ib_check_level); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 119 | |
| 120 | /* Create post mortem control files */ |
| 121 | |
| 122 | pm_d_debugfs = debugfs_create_dir("postmortem", device->d_debugfs); |
| 123 | |
| 124 | if (IS_ERR(pm_d_debugfs)) |
| 125 | return; |
| 126 | |
| 127 | debugfs_create_file("dump", 0600, pm_d_debugfs, device, |
| 128 | &pm_dump_fops); |
| 129 | debugfs_create_file("regs_enabled", 0644, pm_d_debugfs, device, |
| 130 | &pm_regs_enabled_fops); |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 131 | debugfs_create_file("ib_enabled", 0644, pm_d_debugfs, device, |
| 132 | &pm_ib_enabled_fops); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 133 | } |