blob: ecad96524570882b143827c9cfc10aa29c0b9a97 [file] [log] [blame]
Mike Rapoport22caf042006-07-14 00:24:34 -07001#include <linux/debugfs.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09002#include <linux/slab.h>
Mike Rapoport22caf042006-07-14 00:24:34 -07003
4#define BIG_BUFFER_SIZE (1024)
5
6static char big_buffer[BIG_BUFFER_SIZE];
7
8struct mbxfb_debugfs_data {
9 struct dentry *dir;
10 struct dentry *sysconf;
11 struct dentry *clock;
12 struct dentry *display;
13 struct dentry *gsctl;
Raphael Assenat128806c2006-12-08 02:40:35 -080014 struct dentry *sdram;
15 struct dentry *misc;
Mike Rapoport22caf042006-07-14 00:24:34 -070016};
17
18static int open_file_generic(struct inode *inode, struct file *file)
19{
20 file->private_data = inode->u.generic_ip;
21 return 0;
22}
23
24static ssize_t write_file_dummy(struct file *file, const char __user *buf,
25 size_t count, loff_t *ppos)
26{
27 return count;
28}
29
30static ssize_t sysconf_read_file(struct file *file, char __user *userbuf,
31 size_t count, loff_t *ppos)
32{
33 char * s = big_buffer;
34
Raphael Assenat128806c2006-12-08 02:40:35 -080035 s += sprintf(s, "SYSCFG = %08x\n", readl(SYSCFG));
36 s += sprintf(s, "PFBASE = %08x\n", readl(PFBASE));
37 s += sprintf(s, "PFCEIL = %08x\n", readl(PFCEIL));
38 s += sprintf(s, "POLLFLAG = %08x\n", readl(POLLFLAG));
39 s += sprintf(s, "SYSRST = %08x\n", readl(SYSRST));
Mike Rapoport22caf042006-07-14 00:24:34 -070040
41 return simple_read_from_buffer(userbuf, count, ppos,
42 big_buffer, s-big_buffer);
43}
44
45
46static ssize_t gsctl_read_file(struct file *file, char __user *userbuf,
47 size_t count, loff_t *ppos)
48{
49 char * s = big_buffer;
50
Raphael Assenat128806c2006-12-08 02:40:35 -080051 s += sprintf(s, "GSCTRL = %08x\n", readl(GSCTRL));
52 s += sprintf(s, "VSCTRL = %08x\n", readl(VSCTRL));
53 s += sprintf(s, "GBBASE = %08x\n", readl(GBBASE));
54 s += sprintf(s, "VBBASE = %08x\n", readl(VBBASE));
55 s += sprintf(s, "GDRCTRL = %08x\n", readl(GDRCTRL));
56 s += sprintf(s, "VCMSK = %08x\n", readl(VCMSK));
57 s += sprintf(s, "GSCADR = %08x\n", readl(GSCADR));
58 s += sprintf(s, "VSCADR = %08x\n", readl(VSCADR));
59 s += sprintf(s, "VUBASE = %08x\n", readl(VUBASE));
60 s += sprintf(s, "VVBASE = %08x\n", readl(VVBASE));
61 s += sprintf(s, "GSADR = %08x\n", readl(GSADR));
62 s += sprintf(s, "VSADR = %08x\n", readl(VSADR));
63 s += sprintf(s, "HCCTRL = %08x\n", readl(HCCTRL));
64 s += sprintf(s, "HCSIZE = %08x\n", readl(HCSIZE));
65 s += sprintf(s, "HCPOS = %08x\n", readl(HCPOS));
66 s += sprintf(s, "HCBADR = %08x\n", readl(HCBADR));
67 s += sprintf(s, "HCCKMSK = %08x\n", readl(HCCKMSK));
68 s += sprintf(s, "GPLUT = %08x\n", readl(GPLUT));
Mike Rapoport22caf042006-07-14 00:24:34 -070069
70 return simple_read_from_buffer(userbuf, count, ppos,
71 big_buffer, s-big_buffer);
72}
73
74static ssize_t display_read_file(struct file *file, char __user *userbuf,
75 size_t count, loff_t *ppos)
76{
77 char * s = big_buffer;
78
Raphael Assenat128806c2006-12-08 02:40:35 -080079 s += sprintf(s, "DSCTRL = %08x\n", readl(DSCTRL));
80 s += sprintf(s, "DHT01 = %08x\n", readl(DHT01));
81 s += sprintf(s, "DHT02 = %08x\n", readl(DHT02));
82 s += sprintf(s, "DHT03 = %08x\n", readl(DHT03));
83 s += sprintf(s, "DVT01 = %08x\n", readl(DVT01));
84 s += sprintf(s, "DVT02 = %08x\n", readl(DVT02));
85 s += sprintf(s, "DVT03 = %08x\n", readl(DVT03));
86 s += sprintf(s, "DBCOL = %08x\n", readl(DBCOL));
87 s += sprintf(s, "BGCOLOR = %08x\n", readl(BGCOLOR));
88 s += sprintf(s, "DINTRS = %08x\n", readl(DINTRS));
89 s += sprintf(s, "DINTRE = %08x\n", readl(DINTRE));
90 s += sprintf(s, "DINTRCNT = %08x\n", readl(DINTRCNT));
91 s += sprintf(s, "DSIG = %08x\n", readl(DSIG));
92 s += sprintf(s, "DMCTRL = %08x\n", readl(DMCTRL));
93 s += sprintf(s, "CLIPCTRL = %08x\n", readl(CLIPCTRL));
94 s += sprintf(s, "SPOCTRL = %08x\n", readl(SPOCTRL));
95 s += sprintf(s, "SVCTRL = %08x\n", readl(SVCTRL));
96 s += sprintf(s, "DLSTS = %08x\n", readl(DLSTS));
97 s += sprintf(s, "DLLCTRL = %08x\n", readl(DLLCTRL));
98 s += sprintf(s, "DVLNUM = %08x\n", readl(DVLNUM));
99 s += sprintf(s, "DUCTRL = %08x\n", readl(DUCTRL));
100 s += sprintf(s, "DVECTRL = %08x\n", readl(DVECTRL));
101 s += sprintf(s, "DHDET = %08x\n", readl(DHDET));
102 s += sprintf(s, "DVDET = %08x\n", readl(DVDET));
103 s += sprintf(s, "DODMSK = %08x\n", readl(DODMSK));
104 s += sprintf(s, "CSC01 = %08x\n", readl(CSC01));
105 s += sprintf(s, "CSC02 = %08x\n", readl(CSC02));
106 s += sprintf(s, "CSC03 = %08x\n", readl(CSC03));
107 s += sprintf(s, "CSC04 = %08x\n", readl(CSC04));
108 s += sprintf(s, "CSC05 = %08x\n", readl(CSC05));
Mike Rapoport22caf042006-07-14 00:24:34 -0700109
110 return simple_read_from_buffer(userbuf, count, ppos,
111 big_buffer, s-big_buffer);
112}
113
114static ssize_t clock_read_file(struct file *file, char __user *userbuf,
115 size_t count, loff_t *ppos)
116{
117 char * s = big_buffer;
118
Raphael Assenat128806c2006-12-08 02:40:35 -0800119 s += sprintf(s, "SYSCLKSRC = %08x\n", readl(SYSCLKSRC));
120 s += sprintf(s, "PIXCLKSRC = %08x\n", readl(PIXCLKSRC));
121 s += sprintf(s, "CLKSLEEP = %08x\n", readl(CLKSLEEP));
122 s += sprintf(s, "COREPLL = %08x\n", readl(COREPLL));
123 s += sprintf(s, "DISPPLL = %08x\n", readl(DISPPLL));
124 s += sprintf(s, "PLLSTAT = %08x\n", readl(PLLSTAT));
125 s += sprintf(s, "VOVRCLK = %08x\n", readl(VOVRCLK));
126 s += sprintf(s, "PIXCLK = %08x\n", readl(PIXCLK));
127 s += sprintf(s, "MEMCLK = %08x\n", readl(MEMCLK));
128 s += sprintf(s, "M24CLK = %08x\n", readl(M24CLK));
129 s += sprintf(s, "MBXCLK = %08x\n", readl(MBXCLK));
130 s += sprintf(s, "SDCLK = %08x\n", readl(SDCLK));
131 s += sprintf(s, "PIXCLKDIV = %08x\n", readl(PIXCLKDIV));
Mike Rapoport22caf042006-07-14 00:24:34 -0700132
133 return simple_read_from_buffer(userbuf, count, ppos,
134 big_buffer, s-big_buffer);
135}
136
Raphael Assenat128806c2006-12-08 02:40:35 -0800137static ssize_t sdram_read_file(struct file *file, char __user *userbuf,
138 size_t count, loff_t *ppos)
139{
140 char * s = big_buffer;
141
142 s += sprintf(s, "LMRST = %08x\n", readl(LMRST));
143 s += sprintf(s, "LMCFG = %08x\n", readl(LMCFG));
144 s += sprintf(s, "LMPWR = %08x\n", readl(LMPWR));
145 s += sprintf(s, "LMPWRSTAT = %08x\n", readl(LMPWRSTAT));
146 s += sprintf(s, "LMCEMR = %08x\n", readl(LMCEMR));
147 s += sprintf(s, "LMTYPE = %08x\n", readl(LMTYPE));
148 s += sprintf(s, "LMTIM = %08x\n", readl(LMTIM));
149 s += sprintf(s, "LMREFRESH = %08x\n", readl(LMREFRESH));
150 s += sprintf(s, "LMPROTMIN = %08x\n", readl(LMPROTMIN));
151 s += sprintf(s, "LMPROTMAX = %08x\n", readl(LMPROTMAX));
152 s += sprintf(s, "LMPROTCFG = %08x\n", readl(LMPROTCFG));
153 s += sprintf(s, "LMPROTERR = %08x\n", readl(LMPROTERR));
154
155 return simple_read_from_buffer(userbuf, count, ppos,
156 big_buffer, s-big_buffer);
157}
158
159static ssize_t misc_read_file(struct file *file, char __user *userbuf,
160 size_t count, loff_t *ppos)
161{
162 char * s = big_buffer;
163
164 s += sprintf(s, "LCD_CONFIG = %08x\n", readl(LCD_CONFIG));
165 s += sprintf(s, "ODFBPWR = %08x\n", readl(ODFBPWR));
166 s += sprintf(s, "ODFBSTAT = %08x\n", readl(ODFBSTAT));
167 s += sprintf(s, "ID = %08x\n", readl(ID));
168
169 return simple_read_from_buffer(userbuf, count, ppos,
170 big_buffer, s-big_buffer);
171}
172
173
Arjan van de Ven00977a52007-02-12 00:55:34 -0800174static const struct file_operations sysconf_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700175 .read = sysconf_read_file,
176 .write = write_file_dummy,
177 .open = open_file_generic,
178};
179
Arjan van de Ven00977a52007-02-12 00:55:34 -0800180static const struct file_operations clock_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700181 .read = clock_read_file,
182 .write = write_file_dummy,
183 .open = open_file_generic,
184};
185
Arjan van de Ven00977a52007-02-12 00:55:34 -0800186static const struct file_operations display_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700187 .read = display_read_file,
188 .write = write_file_dummy,
189 .open = open_file_generic,
190};
191
Arjan van de Ven00977a52007-02-12 00:55:34 -0800192static const struct file_operations gsctl_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700193 .read = gsctl_read_file,
194 .write = write_file_dummy,
195 .open = open_file_generic,
196};
197
Arjan van de Ven00977a52007-02-12 00:55:34 -0800198static const struct file_operations sdram_fops = {
Raphael Assenat128806c2006-12-08 02:40:35 -0800199 .read = sdram_read_file,
200 .write = write_file_dummy,
201 .open = open_file_generic,
202};
203
Arjan van de Ven00977a52007-02-12 00:55:34 -0800204static const struct file_operations misc_fops = {
Raphael Assenat128806c2006-12-08 02:40:35 -0800205 .read = misc_read_file,
206 .write = write_file_dummy,
207 .open = open_file_generic,
208};
Mike Rapoport22caf042006-07-14 00:24:34 -0700209
210static void __devinit mbxfb_debugfs_init(struct fb_info *fbi)
211{
212 struct mbxfb_info *mfbi = fbi->par;
213 struct mbxfb_debugfs_data *dbg;
214
215 dbg = kzalloc(sizeof(struct mbxfb_debugfs_data), GFP_KERNEL);
216 mfbi->debugfs_data = dbg;
217
218 dbg->dir = debugfs_create_dir("mbxfb", NULL);
219 dbg->sysconf = debugfs_create_file("sysconf", 0444, dbg->dir,
220 fbi, &sysconf_fops);
221 dbg->clock = debugfs_create_file("clock", 0444, dbg->dir,
222 fbi, &clock_fops);
223 dbg->display = debugfs_create_file("display", 0444, dbg->dir,
224 fbi, &display_fops);
225 dbg->gsctl = debugfs_create_file("gsctl", 0444, dbg->dir,
226 fbi, &gsctl_fops);
Raphael Assenat128806c2006-12-08 02:40:35 -0800227 dbg->sdram = debugfs_create_file("sdram", 0444, dbg->dir,
228 fbi, &sdram_fops);
229 dbg->misc = debugfs_create_file("misc", 0444, dbg->dir,
230 fbi, &misc_fops);
Mike Rapoport22caf042006-07-14 00:24:34 -0700231}
232
233static void __devexit mbxfb_debugfs_remove(struct fb_info *fbi)
234{
235 struct mbxfb_info *mfbi = fbi->par;
236 struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data;
237
Raphael Assenat128806c2006-12-08 02:40:35 -0800238 debugfs_remove(dbg->misc);
239 debugfs_remove(dbg->sdram);
Mike Rapoport22caf042006-07-14 00:24:34 -0700240 debugfs_remove(dbg->gsctl);
241 debugfs_remove(dbg->display);
242 debugfs_remove(dbg->clock);
243 debugfs_remove(dbg->sysconf);
244 debugfs_remove(dbg->dir);
245}