Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011, The Linux Foundation. All rights reserved. |
Laxminath Kasam | 1a46111 | 2010-11-15 12:17:26 +0530 | [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 | * You should have received a copy of the GNU General Public License |
| 13 | * along with this program; if not, write to the Free Software |
| 14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 15 | * 02110-1301, USA. |
| 16 | */ |
| 17 | |
| 18 | #include <linux/debugfs.h> |
| 19 | #include <linux/delay.h> |
| 20 | #include <linux/errno.h> |
| 21 | #include <linux/fs.h> |
| 22 | #include <linux/kernel.h> |
| 23 | #include <linux/list.h> |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/mutex.h> |
| 26 | #include <linux/sched.h> |
| 27 | #include <linux/spinlock.h> |
| 28 | #include <linux/string.h> |
| 29 | #include <linux/types.h> |
| 30 | #include <linux/uaccess.h> |
| 31 | #include <linux/wait.h> |
| 32 | |
| 33 | #include <mach/debug_mm.h> |
| 34 | #include <mach/msm_smd.h> |
| 35 | |
| 36 | #include "adsp.h" |
| 37 | |
| 38 | #define MAX_LEN 64 |
| 39 | #ifdef CONFIG_DEBUG_FS |
| 40 | static struct dentry *adsp_dentry; |
| 41 | #endif |
| 42 | static char l_buf[MAX_LEN]; |
| 43 | static unsigned int crash_enable; |
| 44 | |
| 45 | static ssize_t q5_debug_open(struct inode *inode, struct file *file) |
| 46 | { |
| 47 | file->private_data = inode->i_private; |
| 48 | MM_DBG("q5 debugfs opened\n"); |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | static ssize_t q5_debug_write(struct file *file, const char __user *buf, |
| 53 | size_t count, loff_t *ppos) |
| 54 | { |
| 55 | int len; |
| 56 | |
| 57 | if (count < 0) |
| 58 | return 0; |
| 59 | len = count > (MAX_LEN - 1) ? (MAX_LEN - 1) : count; |
| 60 | if (copy_from_user(l_buf, buf, len)) { |
| 61 | MM_INFO("Unable to copy data from user space\n"); |
| 62 | return -EFAULT; |
| 63 | } |
| 64 | l_buf[len] = 0; |
| 65 | if (l_buf[len - 1] == '\n') { |
| 66 | l_buf[len - 1] = 0; |
| 67 | len--; |
| 68 | } |
| 69 | if (!strncmp(l_buf, "boom", MAX_LEN)) { |
| 70 | q5audio_dsp_not_responding(); |
| 71 | } else if (!strncmp(l_buf, "enable", MAX_LEN)) { |
| 72 | crash_enable = 1; |
| 73 | MM_INFO("Crash enabled : %d\n", crash_enable); |
| 74 | } else if (!strncmp(l_buf, "disable", MAX_LEN)) { |
| 75 | crash_enable = 0; |
| 76 | MM_INFO("Crash disabled : %d\n", crash_enable); |
| 77 | } else |
| 78 | MM_INFO("Unknown Command\n"); |
| 79 | |
| 80 | return count; |
| 81 | } |
| 82 | |
| 83 | static const struct file_operations q5_debug_fops = { |
| 84 | .write = q5_debug_write, |
| 85 | .open = q5_debug_open, |
| 86 | }; |
| 87 | |
| 88 | static int __init q5_debug_init(void) |
| 89 | { |
| 90 | #ifdef CONFIG_DEBUG_FS |
| 91 | adsp_dentry = debugfs_create_file("q5_debug", S_IFREG | S_IRUGO, |
| 92 | NULL, (void *) NULL, &q5_debug_fops); |
| 93 | #endif /* CONFIG_DEBUG_FS */ |
| 94 | return 0; |
| 95 | } |
| 96 | device_initcall(q5_debug_init); |
| 97 | |