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 | |
| 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 Gebben | eebc461 | 2011-08-31 10:15:21 -0700 | [diff] [blame] | 23 | #include "a2xx_reg.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 24 | |
| 25 | unsigned int kgsl_cff_dump_enable; |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 26 | int adreno_pm_regs_enabled; |
| 27 | int adreno_pm_ib_enabled; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 28 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 29 | static struct dentry *pm_d_debugfs; |
| 30 | |
| 31 | static 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 | |
| 44 | DEFINE_SIMPLE_ATTRIBUTE(pm_dump_fops, |
| 45 | NULL, |
| 46 | pm_dump_set, "%llu\n"); |
| 47 | |
| 48 | static int pm_regs_enabled_set(void *data, u64 val) |
| 49 | { |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 50 | adreno_pm_regs_enabled = val ? 1 : 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | static int pm_regs_enabled_get(void *data, u64 *val) |
| 55 | { |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 56 | *val = adreno_pm_regs_enabled; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 57 | return 0; |
| 58 | } |
| 59 | |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 60 | static int pm_ib_enabled_set(void *data, u64 val) |
| 61 | { |
| 62 | adreno_pm_ib_enabled = val ? 1 : 0; |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | static int pm_ib_enabled_get(void *data, u64 *val) |
| 67 | { |
| 68 | *val = adreno_pm_ib_enabled; |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 73 | DEFINE_SIMPLE_ATTRIBUTE(pm_regs_enabled_fops, |
| 74 | pm_regs_enabled_get, |
| 75 | pm_regs_enabled_set, "%llu\n"); |
| 76 | |
Harsh Vardhan Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 77 | DEFINE_SIMPLE_ATTRIBUTE(pm_ib_enabled_fops, |
| 78 | pm_ib_enabled_get, |
| 79 | pm_ib_enabled_set, "%llu\n"); |
| 80 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 81 | |
| 82 | static 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 | |
| 92 | static int kgsl_cff_dump_enable_get(void *data, u64 *val) |
| 93 | { |
| 94 | *val = kgsl_cff_dump_enable; |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | DEFINE_SIMPLE_ATTRIBUTE(kgsl_cff_dump_enable_fops, kgsl_cff_dump_enable_get, |
| 99 | kgsl_cff_dump_enable_set, "%llu\n"); |
| 100 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 101 | typedef void (*reg_read_init_t)(struct kgsl_device *device); |
| 102 | typedef void (*reg_read_fill_t)(struct kgsl_device *device, int i, |
| 103 | unsigned int *vals, int linec); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 104 | |
| 105 | void adreno_debugfs_init(struct kgsl_device *device) |
| 106 | { |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 107 | struct adreno_device *adreno_dev = ADRENO_DEVICE(device); |
| 108 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 109 | if (!device->d_debugfs || IS_ERR(device->d_debugfs)) |
| 110 | return; |
| 111 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 112 | debugfs_create_file("cff_dump", 0644, device->d_debugfs, device, |
| 113 | &kgsl_cff_dump_enable_fops); |
Ranjhith Kalisamy | 823c148 | 2011-09-05 20:31:07 +0530 | [diff] [blame] | 114 | debugfs_create_u32("wait_timeout", 0644, device->d_debugfs, |
| 115 | &adreno_dev->wait_timeout); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 116 | |
| 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 Dwivedi | ff6dc29 | 2012-02-23 16:38:30 -0700 | [diff] [blame] | 128 | debugfs_create_file("ib_enabled", 0644, pm_d_debugfs, device, |
| 129 | &pm_ib_enabled_fops); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 130 | } |