GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / staging / msm / mdp4_debugfs.c
blob36954e89478c78cd7f8872ec86fe3eac069aeeb7
1 /* Copyright (c) 2009, Code Aurora Forum. All rights reserved.
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.
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.
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.
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/sched.h>
20 #include <linux/time.h>
21 #include <linux/init.h>
22 #include <linux/interrupt.h>
23 #include <linux/spinlock.h>
24 #include <linux/hrtimer.h>
25 #include <linux/clk.h>
26 #include <mach/hardware.h>
27 #include <linux/io.h>
28 #include <linux/debugfs.h>
30 #include <asm/system.h>
31 #include <asm/mach-types.h>
32 #include <linux/semaphore.h>
33 #include <linux/uaccess.h>
35 #include "mdp.h"
36 #include "msm_fb.h"
37 #include "mdp4.h"
40 #define MDP4_DEBUG_BUF 128
43 static char mdp4_debug_buf[MDP4_DEBUG_BUF];
44 static ulong mdp4_debug_offset;
45 static ulong mdp4_base_addr;
47 static int mdp4_offset_set(void *data, u64 val)
49 mdp4_debug_offset = (int)val;
50 return 0;
53 static int mdp4_offset_get(void *data, u64 *val)
55 *val = (u64)mdp4_debug_offset;
56 return 0;
59 DEFINE_SIMPLE_ATTRIBUTE(
60 mdp4_offset_fops,
61 mdp4_offset_get,
62 mdp4_offset_set,
63 "%llx\n");
66 static int mdp4_debugfs_release(struct inode *inode, struct file *file)
68 return 0;
71 static ssize_t mdp4_debugfs_write(
72 struct file *file,
73 const char __user *buff,
74 size_t count,
75 loff_t *ppos)
77 int cnt;
78 unsigned int data;
80 printk(KERN_INFO "%s: offset=%d count=%d *ppos=%d\n",
81 __func__, (int)mdp4_debug_offset, (int)count, (int)*ppos);
83 if (count > sizeof(mdp4_debug_buf))
84 return -EFAULT;
86 if (copy_from_user(mdp4_debug_buf, buff, count))
87 return -EFAULT;
90 mdp4_debug_buf[count] = 0; /* end of string */
92 cnt = sscanf(mdp4_debug_buf, "%x", &data);
93 if (cnt < 1) {
94 printk(KERN_ERR "%s: sscanf failed cnt=%d" , __func__, cnt);
95 return -EINVAL;
98 writel(&data, mdp4_base_addr + mdp4_debug_offset);
100 return 0;
103 static ssize_t mdp4_debugfs_read(
104 struct file *file,
105 char __user *buff,
106 size_t count,
107 loff_t *ppos)
109 int len = 0;
110 unsigned int data;
112 printk(KERN_INFO "%s: offset=%d count=%d *ppos=%d\n",
113 __func__, (int)mdp4_debug_offset, (int)count, (int)*ppos);
115 if (*ppos)
116 return 0; /* the end */
118 data = readl(mdp4_base_addr + mdp4_debug_offset);
120 len = snprintf(mdp4_debug_buf, 4, "%x\n", data);
122 if (len > 0) {
123 if (len > count)
124 len = count;
125 if (copy_to_user(buff, mdp4_debug_buf, len))
126 return -EFAULT;
129 printk(KERN_INFO "%s: len=%d\n", __func__, len);
131 if (len < 0)
132 return 0;
134 *ppos += len; /* increase offset */
136 return len;
139 static const struct file_operations mdp4_debugfs_fops = {
140 .open = nonseekable_open,
141 .release = mdp4_debugfs_release,
142 .read = mdp4_debugfs_read,
143 .write = mdp4_debugfs_write,
144 .llseek = no_llseek,
147 int mdp4_debugfs_init(void)
149 struct dentry *dent = debugfs_create_dir("mdp4", NULL);
151 if (IS_ERR(dent)) {
152 printk(KERN_ERR "%s(%d): debugfs_create_dir fail, error %ld\n",
153 __FILE__, __LINE__, PTR_ERR(dent));
154 return -1;
157 if (debugfs_create_file("offset", 0644, dent, 0, &mdp4_offset_fops)
158 == NULL) {
159 printk(KERN_ERR "%s(%d): debugfs_create_file: offset fail\n",
160 __FILE__, __LINE__);
161 return -1;
164 if (debugfs_create_file("regs", 0644, dent, 0, &mdp4_debugfs_fops)
165 == NULL) {
166 printk(KERN_ERR "%s(%d): debugfs_create_file: regs fail\n",
167 __FILE__, __LINE__);
168 return -1;
171 mdp4_debug_offset = 0;
172 mdp4_base_addr = (ulong) msm_mdp_base; /* defined at msm_fb_def.h */
174 return 0;