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
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>
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>
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
;
53 static int mdp4_offset_get(void *data
, u64
*val
)
55 *val
= (u64
)mdp4_debug_offset
;
59 DEFINE_SIMPLE_ATTRIBUTE(
66 static int mdp4_debugfs_release(struct inode
*inode
, struct file
*file
)
71 static ssize_t
mdp4_debugfs_write(
73 const char __user
*buff
,
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
))
86 if (copy_from_user(mdp4_debug_buf
, buff
, count
))
90 mdp4_debug_buf
[count
] = 0; /* end of string */
92 cnt
= sscanf(mdp4_debug_buf
, "%x", &data
);
94 printk(KERN_ERR
"%s: sscanf failed cnt=%d" , __func__
, cnt
);
98 writel(&data
, mdp4_base_addr
+ mdp4_debug_offset
);
103 static ssize_t
mdp4_debugfs_read(
112 printk(KERN_INFO
"%s: offset=%d count=%d *ppos=%d\n",
113 __func__
, (int)mdp4_debug_offset
, (int)count
, (int)*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
);
125 if (copy_to_user(buff
, mdp4_debug_buf
, len
))
129 printk(KERN_INFO
"%s: len=%d\n", __func__
, len
);
134 *ppos
+= len
; /* increase offset */
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
,
147 int mdp4_debugfs_init(void)
149 struct dentry
*dent
= debugfs_create_dir("mdp4", NULL
);
152 printk(KERN_ERR
"%s(%d): debugfs_create_dir fail, error %ld\n",
153 __FILE__
, __LINE__
, PTR_ERR(dent
));
157 if (debugfs_create_file("offset", 0644, dent
, 0, &mdp4_offset_fops
)
159 printk(KERN_ERR
"%s(%d): debugfs_create_file: offset fail\n",
164 if (debugfs_create_file("regs", 0644, dent
, 0, &mdp4_debugfs_fops
)
166 printk(KERN_ERR
"%s(%d): debugfs_create_file: regs fail\n",
171 mdp4_debug_offset
= 0;
172 mdp4_base_addr
= (ulong
) msm_mdp_base
; /* defined at msm_fb_def.h */